
obj/user/pingpong:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 c7 00 00 00       	call   8000f8 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <umain>:

#include <inc/lib.h>

void
umain(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	57                   	push   %edi
  800038:	56                   	push   %esi
  800039:	53                   	push   %ebx
  80003a:	83 ec 2c             	sub    $0x2c,%esp
	envid_t who;

	if ((who = fork()) != 0) {
  80003d:	e8 00 11 00 00       	call   801142 <fork>
  800042:	89 c3                	mov    %eax,%ebx
  800044:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800047:	85 c0                	test   %eax,%eax
  800049:	74 3c                	je     800087 <umain+0x53>
		// get the ball rolling
		cprintf("send 0 from %x to %x\n", sys_getenvid(), who);
  80004b:	e8 39 10 00 00       	call   801089 <sys_getenvid>
  800050:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800054:	89 44 24 04          	mov    %eax,0x4(%esp)
  800058:	c7 04 24 40 2d 80 00 	movl   $0x802d40,(%esp)
  80005f:	e8 61 01 00 00       	call   8001c5 <cprintf>
		ipc_send(who, 0, 0, 0);
  800064:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80006b:	00 
  80006c:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  800073:	00 
  800074:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80007b:	00 
  80007c:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80007f:	89 04 24             	mov    %eax,(%esp)
  800082:	e8 99 14 00 00       	call   801520 <ipc_send>
	}

	while (1) {
		uint32_t i = ipc_recv(&who, 0, 0);
  800087:	8d 7d e4             	lea    -0x1c(%ebp),%edi
  80008a:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  800091:	00 
  800092:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800099:	00 
  80009a:	89 3c 24             	mov    %edi,(%esp)
  80009d:	e8 f0 14 00 00       	call   801592 <ipc_recv>
  8000a2:	89 c3                	mov    %eax,%ebx
		cprintf("%x got %d from %x\n", sys_getenvid(), i, who);
  8000a4:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  8000a7:	e8 dd 0f 00 00       	call   801089 <sys_getenvid>
  8000ac:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8000b0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8000b4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000b8:	c7 04 24 56 2d 80 00 	movl   $0x802d56,(%esp)
  8000bf:	e8 01 01 00 00       	call   8001c5 <cprintf>
		if (i == 10)
  8000c4:	83 fb 0a             	cmp    $0xa,%ebx
  8000c7:	74 27                	je     8000f0 <umain+0xbc>
			return;
		i++;
  8000c9:	83 c3 01             	add    $0x1,%ebx
		ipc_send(who, i, 0, 0);
  8000cc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8000d3:	00 
  8000d4:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8000db:	00 
  8000dc:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000e0:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8000e3:	89 04 24             	mov    %eax,(%esp)
  8000e6:	e8 35 14 00 00       	call   801520 <ipc_send>
		if (i == 10)
  8000eb:	83 fb 0a             	cmp    $0xa,%ebx
  8000ee:	75 9a                	jne    80008a <umain+0x56>
			return;
	}
}
  8000f0:	83 c4 2c             	add    $0x2c,%esp
  8000f3:	5b                   	pop    %ebx
  8000f4:	5e                   	pop    %esi
  8000f5:	5f                   	pop    %edi
  8000f6:	5d                   	pop    %ebp
  8000f7:	c3                   	ret    

008000f8 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8000f8:	55                   	push   %ebp
  8000f9:	89 e5                	mov    %esp,%ebp
  8000fb:	83 ec 18             	sub    $0x18,%esp
  8000fe:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800101:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800104:	8b 75 08             	mov    0x8(%ebp),%esi
  800107:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  80010a:	e8 7a 0f 00 00       	call   801089 <sys_getenvid>
	env = &envs [ENVX(envid)];
  80010f:	25 ff 03 00 00       	and    $0x3ff,%eax
  800114:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800117:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80011c:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800121:	85 f6                	test   %esi,%esi
  800123:	7e 07                	jle    80012c <libmain+0x34>
		binaryname = argv[0];
  800125:	8b 03                	mov    (%ebx),%eax
  800127:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  80012c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800130:	89 34 24             	mov    %esi,(%esp)
  800133:	e8 fc fe ff ff       	call   800034 <umain>

	// exit gracefully
	exit();
  800138:	e8 0b 00 00 00       	call   800148 <exit>
}
  80013d:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800140:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800143:	89 ec                	mov    %ebp,%esp
  800145:	5d                   	pop    %ebp
  800146:	c3                   	ret    
	...

00800148 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800148:	55                   	push   %ebp
  800149:	89 e5                	mov    %esp,%ebp
  80014b:	83 ec 18             	sub    $0x18,%esp
	close_all();
  80014e:	e8 d6 19 00 00       	call   801b29 <close_all>
	sys_env_destroy(0);
  800153:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80015a:	e8 5e 0f 00 00       	call   8010bd <sys_env_destroy>
}
  80015f:	c9                   	leave  
  800160:	c3                   	ret    
  800161:	00 00                	add    %al,(%eax)
	...

00800164 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800164:	55                   	push   %ebp
  800165:	89 e5                	mov    %esp,%ebp
  800167:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  80016d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800174:	00 00 00 
	b.cnt = 0;
  800177:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80017e:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800181:	8b 45 0c             	mov    0xc(%ebp),%eax
  800184:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800188:	8b 45 08             	mov    0x8(%ebp),%eax
  80018b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80018f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800195:	89 44 24 04          	mov    %eax,0x4(%esp)
  800199:	c7 04 24 df 01 80 00 	movl   $0x8001df,(%esp)
  8001a0:	e8 d8 01 00 00       	call   80037d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8001a5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8001ab:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001af:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8001b5:	89 04 24             	mov    %eax,(%esp)
  8001b8:	e8 d3 0a 00 00       	call   800c90 <sys_cputs>

	return b.cnt;
}
  8001bd:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8001c3:	c9                   	leave  
  8001c4:	c3                   	ret    

008001c5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8001c5:	55                   	push   %ebp
  8001c6:	89 e5                	mov    %esp,%ebp
  8001c8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8001cb:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8001ce:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001d2:	8b 45 08             	mov    0x8(%ebp),%eax
  8001d5:	89 04 24             	mov    %eax,(%esp)
  8001d8:	e8 87 ff ff ff       	call   800164 <vcprintf>
	va_end(ap);

	return cnt;
}
  8001dd:	c9                   	leave  
  8001de:	c3                   	ret    

008001df <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8001df:	55                   	push   %ebp
  8001e0:	89 e5                	mov    %esp,%ebp
  8001e2:	53                   	push   %ebx
  8001e3:	83 ec 14             	sub    $0x14,%esp
  8001e6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8001e9:	8b 03                	mov    (%ebx),%eax
  8001eb:	8b 55 08             	mov    0x8(%ebp),%edx
  8001ee:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8001f2:	83 c0 01             	add    $0x1,%eax
  8001f5:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8001f7:	3d ff 00 00 00       	cmp    $0xff,%eax
  8001fc:	75 19                	jne    800217 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  8001fe:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800205:	00 
  800206:	8d 43 08             	lea    0x8(%ebx),%eax
  800209:	89 04 24             	mov    %eax,(%esp)
  80020c:	e8 7f 0a 00 00       	call   800c90 <sys_cputs>
		b->idx = 0;
  800211:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800217:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80021b:	83 c4 14             	add    $0x14,%esp
  80021e:	5b                   	pop    %ebx
  80021f:	5d                   	pop    %ebp
  800220:	c3                   	ret    
	...

00800230 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800230:	55                   	push   %ebp
  800231:	89 e5                	mov    %esp,%ebp
  800233:	57                   	push   %edi
  800234:	56                   	push   %esi
  800235:	53                   	push   %ebx
  800236:	83 ec 4c             	sub    $0x4c,%esp
  800239:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80023c:	89 d6                	mov    %edx,%esi
  80023e:	8b 45 08             	mov    0x8(%ebp),%eax
  800241:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800244:	8b 55 0c             	mov    0xc(%ebp),%edx
  800247:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80024a:	8b 45 10             	mov    0x10(%ebp),%eax
  80024d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800250:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800253:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800256:	b9 00 00 00 00       	mov    $0x0,%ecx
  80025b:	39 d1                	cmp    %edx,%ecx
  80025d:	72 15                	jb     800274 <printnum+0x44>
  80025f:	77 07                	ja     800268 <printnum+0x38>
  800261:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800264:	39 d0                	cmp    %edx,%eax
  800266:	76 0c                	jbe    800274 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800268:	83 eb 01             	sub    $0x1,%ebx
  80026b:	85 db                	test   %ebx,%ebx
  80026d:	8d 76 00             	lea    0x0(%esi),%esi
  800270:	7f 61                	jg     8002d3 <printnum+0xa3>
  800272:	eb 70                	jmp    8002e4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800274:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800278:	83 eb 01             	sub    $0x1,%ebx
  80027b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80027f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800283:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800287:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80028b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80028e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800291:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800294:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800298:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80029f:	00 
  8002a0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8002a3:	89 04 24             	mov    %eax,(%esp)
  8002a6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8002a9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8002ad:	e8 1e 28 00 00       	call   802ad0 <__udivdi3>
  8002b2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8002b5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8002b8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8002bc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8002c0:	89 04 24             	mov    %eax,(%esp)
  8002c3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8002c7:	89 f2                	mov    %esi,%edx
  8002c9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8002cc:	e8 5f ff ff ff       	call   800230 <printnum>
  8002d1:	eb 11                	jmp    8002e4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8002d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8002d7:	89 3c 24             	mov    %edi,(%esp)
  8002da:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8002dd:	83 eb 01             	sub    $0x1,%ebx
  8002e0:	85 db                	test   %ebx,%ebx
  8002e2:	7f ef                	jg     8002d3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8002e4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8002e8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8002ec:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8002ef:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002f3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8002fa:	00 
  8002fb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8002fe:	89 14 24             	mov    %edx,(%esp)
  800301:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800304:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800308:	e8 f3 28 00 00       	call   802c00 <__umoddi3>
  80030d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800311:	0f be 80 80 2d 80 00 	movsbl 0x802d80(%eax),%eax
  800318:	89 04 24             	mov    %eax,(%esp)
  80031b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80031e:	83 c4 4c             	add    $0x4c,%esp
  800321:	5b                   	pop    %ebx
  800322:	5e                   	pop    %esi
  800323:	5f                   	pop    %edi
  800324:	5d                   	pop    %ebp
  800325:	c3                   	ret    

00800326 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800326:	55                   	push   %ebp
  800327:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800329:	83 fa 01             	cmp    $0x1,%edx
  80032c:	7e 0e                	jle    80033c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80032e:	8b 10                	mov    (%eax),%edx
  800330:	8d 4a 08             	lea    0x8(%edx),%ecx
  800333:	89 08                	mov    %ecx,(%eax)
  800335:	8b 02                	mov    (%edx),%eax
  800337:	8b 52 04             	mov    0x4(%edx),%edx
  80033a:	eb 22                	jmp    80035e <getuint+0x38>
	else if (lflag)
  80033c:	85 d2                	test   %edx,%edx
  80033e:	74 10                	je     800350 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800340:	8b 10                	mov    (%eax),%edx
  800342:	8d 4a 04             	lea    0x4(%edx),%ecx
  800345:	89 08                	mov    %ecx,(%eax)
  800347:	8b 02                	mov    (%edx),%eax
  800349:	ba 00 00 00 00       	mov    $0x0,%edx
  80034e:	eb 0e                	jmp    80035e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800350:	8b 10                	mov    (%eax),%edx
  800352:	8d 4a 04             	lea    0x4(%edx),%ecx
  800355:	89 08                	mov    %ecx,(%eax)
  800357:	8b 02                	mov    (%edx),%eax
  800359:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80035e:	5d                   	pop    %ebp
  80035f:	c3                   	ret    

00800360 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800360:	55                   	push   %ebp
  800361:	89 e5                	mov    %esp,%ebp
  800363:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800366:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80036a:	8b 10                	mov    (%eax),%edx
  80036c:	3b 50 04             	cmp    0x4(%eax),%edx
  80036f:	73 0a                	jae    80037b <sprintputch+0x1b>
		*b->buf++ = ch;
  800371:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800374:	88 0a                	mov    %cl,(%edx)
  800376:	83 c2 01             	add    $0x1,%edx
  800379:	89 10                	mov    %edx,(%eax)
}
  80037b:	5d                   	pop    %ebp
  80037c:	c3                   	ret    

0080037d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80037d:	55                   	push   %ebp
  80037e:	89 e5                	mov    %esp,%ebp
  800380:	57                   	push   %edi
  800381:	56                   	push   %esi
  800382:	53                   	push   %ebx
  800383:	83 ec 5c             	sub    $0x5c,%esp
  800386:	8b 7d 08             	mov    0x8(%ebp),%edi
  800389:	8b 75 0c             	mov    0xc(%ebp),%esi
  80038c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80038f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800396:	eb 11                	jmp    8003a9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800398:	85 c0                	test   %eax,%eax
  80039a:	0f 84 f9 03 00 00    	je     800799 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8003a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003a4:	89 04 24             	mov    %eax,(%esp)
  8003a7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8003a9:	0f b6 03             	movzbl (%ebx),%eax
  8003ac:	83 c3 01             	add    $0x1,%ebx
  8003af:	83 f8 25             	cmp    $0x25,%eax
  8003b2:	75 e4                	jne    800398 <vprintfmt+0x1b>
  8003b4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8003b8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8003bf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8003c6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8003cd:	b9 00 00 00 00       	mov    $0x0,%ecx
  8003d2:	eb 06                	jmp    8003da <vprintfmt+0x5d>
  8003d4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8003d8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8003da:	0f b6 13             	movzbl (%ebx),%edx
  8003dd:	0f b6 c2             	movzbl %dl,%eax
  8003e0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8003e3:	8d 43 01             	lea    0x1(%ebx),%eax
  8003e6:	83 ea 23             	sub    $0x23,%edx
  8003e9:	80 fa 55             	cmp    $0x55,%dl
  8003ec:	0f 87 8a 03 00 00    	ja     80077c <vprintfmt+0x3ff>
  8003f2:	0f b6 d2             	movzbl %dl,%edx
  8003f5:	ff 24 95 c0 2e 80 00 	jmp    *0x802ec0(,%edx,4)
  8003fc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800400:	eb d6                	jmp    8003d8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800402:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800405:	83 ea 30             	sub    $0x30,%edx
  800408:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80040b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80040e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800411:	83 fb 09             	cmp    $0x9,%ebx
  800414:	77 54                	ja     80046a <vprintfmt+0xed>
  800416:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800419:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80041c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80041f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800422:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800426:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800429:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80042c:	83 fb 09             	cmp    $0x9,%ebx
  80042f:	76 eb                	jbe    80041c <vprintfmt+0x9f>
  800431:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800434:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800437:	eb 31                	jmp    80046a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800439:	8b 55 14             	mov    0x14(%ebp),%edx
  80043c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80043f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800442:	8b 12                	mov    (%edx),%edx
  800444:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800447:	eb 21                	jmp    80046a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800449:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80044d:	ba 00 00 00 00       	mov    $0x0,%edx
  800452:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800456:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800459:	e9 7a ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
  80045e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800465:	e9 6e ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80046a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80046e:	0f 89 64 ff ff ff    	jns    8003d8 <vprintfmt+0x5b>
  800474:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800477:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80047a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80047d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800480:	e9 53 ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800485:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800488:	e9 4b ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
  80048d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800490:	8b 45 14             	mov    0x14(%ebp),%eax
  800493:	8d 50 04             	lea    0x4(%eax),%edx
  800496:	89 55 14             	mov    %edx,0x14(%ebp)
  800499:	89 74 24 04          	mov    %esi,0x4(%esp)
  80049d:	8b 00                	mov    (%eax),%eax
  80049f:	89 04 24             	mov    %eax,(%esp)
  8004a2:	ff d7                	call   *%edi
  8004a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8004a7:	e9 fd fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  8004ac:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8004af:	8b 45 14             	mov    0x14(%ebp),%eax
  8004b2:	8d 50 04             	lea    0x4(%eax),%edx
  8004b5:	89 55 14             	mov    %edx,0x14(%ebp)
  8004b8:	8b 00                	mov    (%eax),%eax
  8004ba:	89 c2                	mov    %eax,%edx
  8004bc:	c1 fa 1f             	sar    $0x1f,%edx
  8004bf:	31 d0                	xor    %edx,%eax
  8004c1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8004c3:	83 f8 12             	cmp    $0x12,%eax
  8004c6:	7f 0b                	jg     8004d3 <vprintfmt+0x156>
  8004c8:	8b 14 85 20 30 80 00 	mov    0x803020(,%eax,4),%edx
  8004cf:	85 d2                	test   %edx,%edx
  8004d1:	75 20                	jne    8004f3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8004d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004d7:	c7 44 24 08 91 2d 80 	movl   $0x802d91,0x8(%esp)
  8004de:	00 
  8004df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004e3:	89 3c 24             	mov    %edi,(%esp)
  8004e6:	e8 36 03 00 00       	call   800821 <printfmt>
  8004eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8004ee:	e9 b6 fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8004f3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8004f7:	c7 44 24 08 62 33 80 	movl   $0x803362,0x8(%esp)
  8004fe:	00 
  8004ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800503:	89 3c 24             	mov    %edi,(%esp)
  800506:	e8 16 03 00 00       	call   800821 <printfmt>
  80050b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80050e:	e9 96 fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  800513:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800516:	89 c3                	mov    %eax,%ebx
  800518:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80051b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80051e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800521:	8b 45 14             	mov    0x14(%ebp),%eax
  800524:	8d 50 04             	lea    0x4(%eax),%edx
  800527:	89 55 14             	mov    %edx,0x14(%ebp)
  80052a:	8b 00                	mov    (%eax),%eax
  80052c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80052f:	85 c0                	test   %eax,%eax
  800531:	b8 9a 2d 80 00       	mov    $0x802d9a,%eax
  800536:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80053a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80053d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800541:	7e 06                	jle    800549 <vprintfmt+0x1cc>
  800543:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800547:	75 13                	jne    80055c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800549:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80054c:	0f be 02             	movsbl (%edx),%eax
  80054f:	85 c0                	test   %eax,%eax
  800551:	0f 85 9b 00 00 00    	jne    8005f2 <vprintfmt+0x275>
  800557:	e9 88 00 00 00       	jmp    8005e4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80055c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800560:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800563:	89 0c 24             	mov    %ecx,(%esp)
  800566:	e8 00 03 00 00       	call   80086b <strnlen>
  80056b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80056e:	29 c2                	sub    %eax,%edx
  800570:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800573:	85 d2                	test   %edx,%edx
  800575:	7e d2                	jle    800549 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800577:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80057b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80057e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800581:	89 d3                	mov    %edx,%ebx
  800583:	89 74 24 04          	mov    %esi,0x4(%esp)
  800587:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80058a:	89 04 24             	mov    %eax,(%esp)
  80058d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80058f:	83 eb 01             	sub    $0x1,%ebx
  800592:	85 db                	test   %ebx,%ebx
  800594:	7f ed                	jg     800583 <vprintfmt+0x206>
  800596:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800599:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8005a0:	eb a7                	jmp    800549 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8005a2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8005a6:	74 1a                	je     8005c2 <vprintfmt+0x245>
  8005a8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8005ab:	83 fa 5e             	cmp    $0x5e,%edx
  8005ae:	76 12                	jbe    8005c2 <vprintfmt+0x245>
					putch('?', putdat);
  8005b0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8005b4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8005bb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8005be:	66 90                	xchg   %ax,%ax
  8005c0:	eb 0a                	jmp    8005cc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8005c2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8005c6:	89 04 24             	mov    %eax,(%esp)
  8005c9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8005cc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8005d0:	0f be 03             	movsbl (%ebx),%eax
  8005d3:	85 c0                	test   %eax,%eax
  8005d5:	74 05                	je     8005dc <vprintfmt+0x25f>
  8005d7:	83 c3 01             	add    $0x1,%ebx
  8005da:	eb 29                	jmp    800605 <vprintfmt+0x288>
  8005dc:	89 fe                	mov    %edi,%esi
  8005de:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8005e1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8005e4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8005e8:	7f 2e                	jg     800618 <vprintfmt+0x29b>
  8005ea:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8005ed:	e9 b7 fd ff ff       	jmp    8003a9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8005f2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8005f5:	83 c2 01             	add    $0x1,%edx
  8005f8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8005fb:	89 f7                	mov    %esi,%edi
  8005fd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800600:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800603:	89 d3                	mov    %edx,%ebx
  800605:	85 f6                	test   %esi,%esi
  800607:	78 99                	js     8005a2 <vprintfmt+0x225>
  800609:	83 ee 01             	sub    $0x1,%esi
  80060c:	79 94                	jns    8005a2 <vprintfmt+0x225>
  80060e:	89 fe                	mov    %edi,%esi
  800610:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800613:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800616:	eb cc                	jmp    8005e4 <vprintfmt+0x267>
  800618:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80061b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80061e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800622:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800629:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80062b:	83 eb 01             	sub    $0x1,%ebx
  80062e:	85 db                	test   %ebx,%ebx
  800630:	7f ec                	jg     80061e <vprintfmt+0x2a1>
  800632:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800635:	e9 6f fd ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  80063a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80063d:	83 f9 01             	cmp    $0x1,%ecx
  800640:	7e 16                	jle    800658 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800642:	8b 45 14             	mov    0x14(%ebp),%eax
  800645:	8d 50 08             	lea    0x8(%eax),%edx
  800648:	89 55 14             	mov    %edx,0x14(%ebp)
  80064b:	8b 10                	mov    (%eax),%edx
  80064d:	8b 48 04             	mov    0x4(%eax),%ecx
  800650:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800653:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800656:	eb 32                	jmp    80068a <vprintfmt+0x30d>
	else if (lflag)
  800658:	85 c9                	test   %ecx,%ecx
  80065a:	74 18                	je     800674 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80065c:	8b 45 14             	mov    0x14(%ebp),%eax
  80065f:	8d 50 04             	lea    0x4(%eax),%edx
  800662:	89 55 14             	mov    %edx,0x14(%ebp)
  800665:	8b 00                	mov    (%eax),%eax
  800667:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80066a:	89 c1                	mov    %eax,%ecx
  80066c:	c1 f9 1f             	sar    $0x1f,%ecx
  80066f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800672:	eb 16                	jmp    80068a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800674:	8b 45 14             	mov    0x14(%ebp),%eax
  800677:	8d 50 04             	lea    0x4(%eax),%edx
  80067a:	89 55 14             	mov    %edx,0x14(%ebp)
  80067d:	8b 00                	mov    (%eax),%eax
  80067f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800682:	89 c2                	mov    %eax,%edx
  800684:	c1 fa 1f             	sar    $0x1f,%edx
  800687:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80068a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80068d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800690:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800695:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800699:	0f 89 9b 00 00 00    	jns    80073a <vprintfmt+0x3bd>
				putch('-', putdat);
  80069f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006a3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8006aa:	ff d7                	call   *%edi
				num = -(long long) num;
  8006ac:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8006af:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8006b2:	f7 d9                	neg    %ecx
  8006b4:	83 d3 00             	adc    $0x0,%ebx
  8006b7:	f7 db                	neg    %ebx
  8006b9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8006be:	eb 7a                	jmp    80073a <vprintfmt+0x3bd>
  8006c0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8006c3:	89 ca                	mov    %ecx,%edx
  8006c5:	8d 45 14             	lea    0x14(%ebp),%eax
  8006c8:	e8 59 fc ff ff       	call   800326 <getuint>
  8006cd:	89 c1                	mov    %eax,%ecx
  8006cf:	89 d3                	mov    %edx,%ebx
  8006d1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8006d6:	eb 62                	jmp    80073a <vprintfmt+0x3bd>
  8006d8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8006db:	89 ca                	mov    %ecx,%edx
  8006dd:	8d 45 14             	lea    0x14(%ebp),%eax
  8006e0:	e8 41 fc ff ff       	call   800326 <getuint>
  8006e5:	89 c1                	mov    %eax,%ecx
  8006e7:	89 d3                	mov    %edx,%ebx
  8006e9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8006ee:	eb 4a                	jmp    80073a <vprintfmt+0x3bd>
  8006f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8006f3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006f7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8006fe:	ff d7                	call   *%edi
			putch('x', putdat);
  800700:	89 74 24 04          	mov    %esi,0x4(%esp)
  800704:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80070b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80070d:	8b 45 14             	mov    0x14(%ebp),%eax
  800710:	8d 50 04             	lea    0x4(%eax),%edx
  800713:	89 55 14             	mov    %edx,0x14(%ebp)
  800716:	8b 08                	mov    (%eax),%ecx
  800718:	bb 00 00 00 00       	mov    $0x0,%ebx
  80071d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800722:	eb 16                	jmp    80073a <vprintfmt+0x3bd>
  800724:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800727:	89 ca                	mov    %ecx,%edx
  800729:	8d 45 14             	lea    0x14(%ebp),%eax
  80072c:	e8 f5 fb ff ff       	call   800326 <getuint>
  800731:	89 c1                	mov    %eax,%ecx
  800733:	89 d3                	mov    %edx,%ebx
  800735:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80073a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80073e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800742:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800745:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800749:	89 44 24 08          	mov    %eax,0x8(%esp)
  80074d:	89 0c 24             	mov    %ecx,(%esp)
  800750:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800754:	89 f2                	mov    %esi,%edx
  800756:	89 f8                	mov    %edi,%eax
  800758:	e8 d3 fa ff ff       	call   800230 <printnum>
  80075d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800760:	e9 44 fc ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  800765:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800768:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80076b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80076f:	89 14 24             	mov    %edx,(%esp)
  800772:	ff d7                	call   *%edi
  800774:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800777:	e9 2d fc ff ff       	jmp    8003a9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80077c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800780:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800787:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800789:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80078c:	80 38 25             	cmpb   $0x25,(%eax)
  80078f:	0f 84 14 fc ff ff    	je     8003a9 <vprintfmt+0x2c>
  800795:	89 c3                	mov    %eax,%ebx
  800797:	eb f0                	jmp    800789 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800799:	83 c4 5c             	add    $0x5c,%esp
  80079c:	5b                   	pop    %ebx
  80079d:	5e                   	pop    %esi
  80079e:	5f                   	pop    %edi
  80079f:	5d                   	pop    %ebp
  8007a0:	c3                   	ret    

008007a1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8007a1:	55                   	push   %ebp
  8007a2:	89 e5                	mov    %esp,%ebp
  8007a4:	83 ec 28             	sub    $0x28,%esp
  8007a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8007aa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8007ad:	85 c0                	test   %eax,%eax
  8007af:	74 04                	je     8007b5 <vsnprintf+0x14>
  8007b1:	85 d2                	test   %edx,%edx
  8007b3:	7f 07                	jg     8007bc <vsnprintf+0x1b>
  8007b5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8007ba:	eb 3b                	jmp    8007f7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8007bc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8007bf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8007c3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8007c6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8007cd:	8b 45 14             	mov    0x14(%ebp),%eax
  8007d0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8007d4:	8b 45 10             	mov    0x10(%ebp),%eax
  8007d7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8007db:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8007de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8007e2:	c7 04 24 60 03 80 00 	movl   $0x800360,(%esp)
  8007e9:	e8 8f fb ff ff       	call   80037d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8007ee:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8007f1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8007f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8007f7:	c9                   	leave  
  8007f8:	c3                   	ret    

008007f9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8007f9:	55                   	push   %ebp
  8007fa:	89 e5                	mov    %esp,%ebp
  8007fc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8007ff:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800802:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800806:	8b 45 10             	mov    0x10(%ebp),%eax
  800809:	89 44 24 08          	mov    %eax,0x8(%esp)
  80080d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800810:	89 44 24 04          	mov    %eax,0x4(%esp)
  800814:	8b 45 08             	mov    0x8(%ebp),%eax
  800817:	89 04 24             	mov    %eax,(%esp)
  80081a:	e8 82 ff ff ff       	call   8007a1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80081f:	c9                   	leave  
  800820:	c3                   	ret    

00800821 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800821:	55                   	push   %ebp
  800822:	89 e5                	mov    %esp,%ebp
  800824:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800827:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80082a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80082e:	8b 45 10             	mov    0x10(%ebp),%eax
  800831:	89 44 24 08          	mov    %eax,0x8(%esp)
  800835:	8b 45 0c             	mov    0xc(%ebp),%eax
  800838:	89 44 24 04          	mov    %eax,0x4(%esp)
  80083c:	8b 45 08             	mov    0x8(%ebp),%eax
  80083f:	89 04 24             	mov    %eax,(%esp)
  800842:	e8 36 fb ff ff       	call   80037d <vprintfmt>
	va_end(ap);
}
  800847:	c9                   	leave  
  800848:	c3                   	ret    
  800849:	00 00                	add    %al,(%eax)
  80084b:	00 00                	add    %al,(%eax)
  80084d:	00 00                	add    %al,(%eax)
	...

00800850 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800850:	55                   	push   %ebp
  800851:	89 e5                	mov    %esp,%ebp
  800853:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800856:	b8 00 00 00 00       	mov    $0x0,%eax
  80085b:	80 3a 00             	cmpb   $0x0,(%edx)
  80085e:	74 09                	je     800869 <strlen+0x19>
		n++;
  800860:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800863:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800867:	75 f7                	jne    800860 <strlen+0x10>
		n++;
	return n;
}
  800869:	5d                   	pop    %ebp
  80086a:	c3                   	ret    

0080086b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80086b:	55                   	push   %ebp
  80086c:	89 e5                	mov    %esp,%ebp
  80086e:	53                   	push   %ebx
  80086f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800872:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800875:	85 c9                	test   %ecx,%ecx
  800877:	74 19                	je     800892 <strnlen+0x27>
  800879:	80 3b 00             	cmpb   $0x0,(%ebx)
  80087c:	74 14                	je     800892 <strnlen+0x27>
  80087e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800883:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800886:	39 c8                	cmp    %ecx,%eax
  800888:	74 0d                	je     800897 <strnlen+0x2c>
  80088a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80088e:	75 f3                	jne    800883 <strnlen+0x18>
  800890:	eb 05                	jmp    800897 <strnlen+0x2c>
  800892:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800897:	5b                   	pop    %ebx
  800898:	5d                   	pop    %ebp
  800899:	c3                   	ret    

0080089a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80089a:	55                   	push   %ebp
  80089b:	89 e5                	mov    %esp,%ebp
  80089d:	53                   	push   %ebx
  80089e:	8b 45 08             	mov    0x8(%ebp),%eax
  8008a1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8008a4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8008a9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8008ad:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8008b0:	83 c2 01             	add    $0x1,%edx
  8008b3:	84 c9                	test   %cl,%cl
  8008b5:	75 f2                	jne    8008a9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8008b7:	5b                   	pop    %ebx
  8008b8:	5d                   	pop    %ebp
  8008b9:	c3                   	ret    

008008ba <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8008ba:	55                   	push   %ebp
  8008bb:	89 e5                	mov    %esp,%ebp
  8008bd:	56                   	push   %esi
  8008be:	53                   	push   %ebx
  8008bf:	8b 45 08             	mov    0x8(%ebp),%eax
  8008c2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8008c5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8008c8:	85 f6                	test   %esi,%esi
  8008ca:	74 18                	je     8008e4 <strncpy+0x2a>
  8008cc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  8008d1:	0f b6 1a             	movzbl (%edx),%ebx
  8008d4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8008d7:	80 3a 01             	cmpb   $0x1,(%edx)
  8008da:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8008dd:	83 c1 01             	add    $0x1,%ecx
  8008e0:	39 ce                	cmp    %ecx,%esi
  8008e2:	77 ed                	ja     8008d1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8008e4:	5b                   	pop    %ebx
  8008e5:	5e                   	pop    %esi
  8008e6:	5d                   	pop    %ebp
  8008e7:	c3                   	ret    

008008e8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8008e8:	55                   	push   %ebp
  8008e9:	89 e5                	mov    %esp,%ebp
  8008eb:	56                   	push   %esi
  8008ec:	53                   	push   %ebx
  8008ed:	8b 75 08             	mov    0x8(%ebp),%esi
  8008f0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8008f3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8008f6:	89 f0                	mov    %esi,%eax
  8008f8:	85 c9                	test   %ecx,%ecx
  8008fa:	74 27                	je     800923 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8008fc:	83 e9 01             	sub    $0x1,%ecx
  8008ff:	74 1d                	je     80091e <strlcpy+0x36>
  800901:	0f b6 1a             	movzbl (%edx),%ebx
  800904:	84 db                	test   %bl,%bl
  800906:	74 16                	je     80091e <strlcpy+0x36>
			*dst++ = *src++;
  800908:	88 18                	mov    %bl,(%eax)
  80090a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  80090d:	83 e9 01             	sub    $0x1,%ecx
  800910:	74 0e                	je     800920 <strlcpy+0x38>
			*dst++ = *src++;
  800912:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800915:	0f b6 1a             	movzbl (%edx),%ebx
  800918:	84 db                	test   %bl,%bl
  80091a:	75 ec                	jne    800908 <strlcpy+0x20>
  80091c:	eb 02                	jmp    800920 <strlcpy+0x38>
  80091e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800920:	c6 00 00             	movb   $0x0,(%eax)
  800923:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800925:	5b                   	pop    %ebx
  800926:	5e                   	pop    %esi
  800927:	5d                   	pop    %ebp
  800928:	c3                   	ret    

00800929 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800929:	55                   	push   %ebp
  80092a:	89 e5                	mov    %esp,%ebp
  80092c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80092f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800932:	0f b6 01             	movzbl (%ecx),%eax
  800935:	84 c0                	test   %al,%al
  800937:	74 15                	je     80094e <strcmp+0x25>
  800939:	3a 02                	cmp    (%edx),%al
  80093b:	75 11                	jne    80094e <strcmp+0x25>
		p++, q++;
  80093d:	83 c1 01             	add    $0x1,%ecx
  800940:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800943:	0f b6 01             	movzbl (%ecx),%eax
  800946:	84 c0                	test   %al,%al
  800948:	74 04                	je     80094e <strcmp+0x25>
  80094a:	3a 02                	cmp    (%edx),%al
  80094c:	74 ef                	je     80093d <strcmp+0x14>
  80094e:	0f b6 c0             	movzbl %al,%eax
  800951:	0f b6 12             	movzbl (%edx),%edx
  800954:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800956:	5d                   	pop    %ebp
  800957:	c3                   	ret    

00800958 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800958:	55                   	push   %ebp
  800959:	89 e5                	mov    %esp,%ebp
  80095b:	53                   	push   %ebx
  80095c:	8b 55 08             	mov    0x8(%ebp),%edx
  80095f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800962:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800965:	85 c0                	test   %eax,%eax
  800967:	74 23                	je     80098c <strncmp+0x34>
  800969:	0f b6 1a             	movzbl (%edx),%ebx
  80096c:	84 db                	test   %bl,%bl
  80096e:	74 24                	je     800994 <strncmp+0x3c>
  800970:	3a 19                	cmp    (%ecx),%bl
  800972:	75 20                	jne    800994 <strncmp+0x3c>
  800974:	83 e8 01             	sub    $0x1,%eax
  800977:	74 13                	je     80098c <strncmp+0x34>
		n--, p++, q++;
  800979:	83 c2 01             	add    $0x1,%edx
  80097c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  80097f:	0f b6 1a             	movzbl (%edx),%ebx
  800982:	84 db                	test   %bl,%bl
  800984:	74 0e                	je     800994 <strncmp+0x3c>
  800986:	3a 19                	cmp    (%ecx),%bl
  800988:	74 ea                	je     800974 <strncmp+0x1c>
  80098a:	eb 08                	jmp    800994 <strncmp+0x3c>
  80098c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800991:	5b                   	pop    %ebx
  800992:	5d                   	pop    %ebp
  800993:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800994:	0f b6 02             	movzbl (%edx),%eax
  800997:	0f b6 11             	movzbl (%ecx),%edx
  80099a:	29 d0                	sub    %edx,%eax
  80099c:	eb f3                	jmp    800991 <strncmp+0x39>

0080099e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  80099e:	55                   	push   %ebp
  80099f:	89 e5                	mov    %esp,%ebp
  8009a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8009a4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8009a8:	0f b6 10             	movzbl (%eax),%edx
  8009ab:	84 d2                	test   %dl,%dl
  8009ad:	74 15                	je     8009c4 <strchr+0x26>
		if (*s == c)
  8009af:	38 ca                	cmp    %cl,%dl
  8009b1:	75 07                	jne    8009ba <strchr+0x1c>
  8009b3:	eb 14                	jmp    8009c9 <strchr+0x2b>
  8009b5:	38 ca                	cmp    %cl,%dl
  8009b7:	90                   	nop
  8009b8:	74 0f                	je     8009c9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  8009ba:	83 c0 01             	add    $0x1,%eax
  8009bd:	0f b6 10             	movzbl (%eax),%edx
  8009c0:	84 d2                	test   %dl,%dl
  8009c2:	75 f1                	jne    8009b5 <strchr+0x17>
  8009c4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  8009c9:	5d                   	pop    %ebp
  8009ca:	c3                   	ret    

008009cb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  8009cb:	55                   	push   %ebp
  8009cc:	89 e5                	mov    %esp,%ebp
  8009ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8009d1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8009d5:	0f b6 10             	movzbl (%eax),%edx
  8009d8:	84 d2                	test   %dl,%dl
  8009da:	74 18                	je     8009f4 <strfind+0x29>
		if (*s == c)
  8009dc:	38 ca                	cmp    %cl,%dl
  8009de:	75 0a                	jne    8009ea <strfind+0x1f>
  8009e0:	eb 12                	jmp    8009f4 <strfind+0x29>
  8009e2:	38 ca                	cmp    %cl,%dl
  8009e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8009e8:	74 0a                	je     8009f4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  8009ea:	83 c0 01             	add    $0x1,%eax
  8009ed:	0f b6 10             	movzbl (%eax),%edx
  8009f0:	84 d2                	test   %dl,%dl
  8009f2:	75 ee                	jne    8009e2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  8009f4:	5d                   	pop    %ebp
  8009f5:	c3                   	ret    

008009f6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  8009f6:	55                   	push   %ebp
  8009f7:	89 e5                	mov    %esp,%ebp
  8009f9:	83 ec 0c             	sub    $0xc,%esp
  8009fc:	89 1c 24             	mov    %ebx,(%esp)
  8009ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a03:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800a07:	8b 7d 08             	mov    0x8(%ebp),%edi
  800a0a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a0d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800a10:	85 c9                	test   %ecx,%ecx
  800a12:	74 30                	je     800a44 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800a14:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800a1a:	75 25                	jne    800a41 <memset+0x4b>
  800a1c:	f6 c1 03             	test   $0x3,%cl
  800a1f:	75 20                	jne    800a41 <memset+0x4b>
		c &= 0xFF;
  800a21:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800a24:	89 d3                	mov    %edx,%ebx
  800a26:	c1 e3 08             	shl    $0x8,%ebx
  800a29:	89 d6                	mov    %edx,%esi
  800a2b:	c1 e6 18             	shl    $0x18,%esi
  800a2e:	89 d0                	mov    %edx,%eax
  800a30:	c1 e0 10             	shl    $0x10,%eax
  800a33:	09 f0                	or     %esi,%eax
  800a35:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800a37:	09 d8                	or     %ebx,%eax
  800a39:	c1 e9 02             	shr    $0x2,%ecx
  800a3c:	fc                   	cld    
  800a3d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800a3f:	eb 03                	jmp    800a44 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800a41:	fc                   	cld    
  800a42:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800a44:	89 f8                	mov    %edi,%eax
  800a46:	8b 1c 24             	mov    (%esp),%ebx
  800a49:	8b 74 24 04          	mov    0x4(%esp),%esi
  800a4d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800a51:	89 ec                	mov    %ebp,%esp
  800a53:	5d                   	pop    %ebp
  800a54:	c3                   	ret    

00800a55 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800a55:	55                   	push   %ebp
  800a56:	89 e5                	mov    %esp,%ebp
  800a58:	83 ec 08             	sub    $0x8,%esp
  800a5b:	89 34 24             	mov    %esi,(%esp)
  800a5e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800a62:	8b 45 08             	mov    0x8(%ebp),%eax
  800a65:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800a68:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800a6b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800a6d:	39 c6                	cmp    %eax,%esi
  800a6f:	73 35                	jae    800aa6 <memmove+0x51>
  800a71:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800a74:	39 d0                	cmp    %edx,%eax
  800a76:	73 2e                	jae    800aa6 <memmove+0x51>
		s += n;
		d += n;
  800a78:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800a7a:	f6 c2 03             	test   $0x3,%dl
  800a7d:	75 1b                	jne    800a9a <memmove+0x45>
  800a7f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800a85:	75 13                	jne    800a9a <memmove+0x45>
  800a87:	f6 c1 03             	test   $0x3,%cl
  800a8a:	75 0e                	jne    800a9a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800a8c:	83 ef 04             	sub    $0x4,%edi
  800a8f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800a92:	c1 e9 02             	shr    $0x2,%ecx
  800a95:	fd                   	std    
  800a96:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800a98:	eb 09                	jmp    800aa3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800a9a:	83 ef 01             	sub    $0x1,%edi
  800a9d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800aa0:	fd                   	std    
  800aa1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800aa3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800aa4:	eb 20                	jmp    800ac6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800aa6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800aac:	75 15                	jne    800ac3 <memmove+0x6e>
  800aae:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800ab4:	75 0d                	jne    800ac3 <memmove+0x6e>
  800ab6:	f6 c1 03             	test   $0x3,%cl
  800ab9:	75 08                	jne    800ac3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800abb:	c1 e9 02             	shr    $0x2,%ecx
  800abe:	fc                   	cld    
  800abf:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800ac1:	eb 03                	jmp    800ac6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800ac3:	fc                   	cld    
  800ac4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800ac6:	8b 34 24             	mov    (%esp),%esi
  800ac9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800acd:	89 ec                	mov    %ebp,%esp
  800acf:	5d                   	pop    %ebp
  800ad0:	c3                   	ret    

00800ad1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800ad1:	55                   	push   %ebp
  800ad2:	89 e5                	mov    %esp,%ebp
  800ad4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800ad7:	8b 45 10             	mov    0x10(%ebp),%eax
  800ada:	89 44 24 08          	mov    %eax,0x8(%esp)
  800ade:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ae1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800ae5:	8b 45 08             	mov    0x8(%ebp),%eax
  800ae8:	89 04 24             	mov    %eax,(%esp)
  800aeb:	e8 65 ff ff ff       	call   800a55 <memmove>
}
  800af0:	c9                   	leave  
  800af1:	c3                   	ret    

00800af2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800af2:	55                   	push   %ebp
  800af3:	89 e5                	mov    %esp,%ebp
  800af5:	57                   	push   %edi
  800af6:	56                   	push   %esi
  800af7:	53                   	push   %ebx
  800af8:	8b 75 08             	mov    0x8(%ebp),%esi
  800afb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800afe:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800b01:	85 c9                	test   %ecx,%ecx
  800b03:	74 36                	je     800b3b <memcmp+0x49>
		if (*s1 != *s2)
  800b05:	0f b6 06             	movzbl (%esi),%eax
  800b08:	0f b6 1f             	movzbl (%edi),%ebx
  800b0b:	38 d8                	cmp    %bl,%al
  800b0d:	74 20                	je     800b2f <memcmp+0x3d>
  800b0f:	eb 14                	jmp    800b25 <memcmp+0x33>
  800b11:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800b16:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800b1b:	83 c2 01             	add    $0x1,%edx
  800b1e:	83 e9 01             	sub    $0x1,%ecx
  800b21:	38 d8                	cmp    %bl,%al
  800b23:	74 12                	je     800b37 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800b25:	0f b6 c0             	movzbl %al,%eax
  800b28:	0f b6 db             	movzbl %bl,%ebx
  800b2b:	29 d8                	sub    %ebx,%eax
  800b2d:	eb 11                	jmp    800b40 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800b2f:	83 e9 01             	sub    $0x1,%ecx
  800b32:	ba 00 00 00 00       	mov    $0x0,%edx
  800b37:	85 c9                	test   %ecx,%ecx
  800b39:	75 d6                	jne    800b11 <memcmp+0x1f>
  800b3b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800b40:	5b                   	pop    %ebx
  800b41:	5e                   	pop    %esi
  800b42:	5f                   	pop    %edi
  800b43:	5d                   	pop    %ebp
  800b44:	c3                   	ret    

00800b45 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800b45:	55                   	push   %ebp
  800b46:	89 e5                	mov    %esp,%ebp
  800b48:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800b4b:	89 c2                	mov    %eax,%edx
  800b4d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800b50:	39 d0                	cmp    %edx,%eax
  800b52:	73 15                	jae    800b69 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800b54:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800b58:	38 08                	cmp    %cl,(%eax)
  800b5a:	75 06                	jne    800b62 <memfind+0x1d>
  800b5c:	eb 0b                	jmp    800b69 <memfind+0x24>
  800b5e:	38 08                	cmp    %cl,(%eax)
  800b60:	74 07                	je     800b69 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800b62:	83 c0 01             	add    $0x1,%eax
  800b65:	39 c2                	cmp    %eax,%edx
  800b67:	77 f5                	ja     800b5e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800b69:	5d                   	pop    %ebp
  800b6a:	c3                   	ret    

00800b6b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800b6b:	55                   	push   %ebp
  800b6c:	89 e5                	mov    %esp,%ebp
  800b6e:	57                   	push   %edi
  800b6f:	56                   	push   %esi
  800b70:	53                   	push   %ebx
  800b71:	83 ec 04             	sub    $0x4,%esp
  800b74:	8b 55 08             	mov    0x8(%ebp),%edx
  800b77:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800b7a:	0f b6 02             	movzbl (%edx),%eax
  800b7d:	3c 20                	cmp    $0x20,%al
  800b7f:	74 04                	je     800b85 <strtol+0x1a>
  800b81:	3c 09                	cmp    $0x9,%al
  800b83:	75 0e                	jne    800b93 <strtol+0x28>
		s++;
  800b85:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800b88:	0f b6 02             	movzbl (%edx),%eax
  800b8b:	3c 20                	cmp    $0x20,%al
  800b8d:	74 f6                	je     800b85 <strtol+0x1a>
  800b8f:	3c 09                	cmp    $0x9,%al
  800b91:	74 f2                	je     800b85 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800b93:	3c 2b                	cmp    $0x2b,%al
  800b95:	75 0c                	jne    800ba3 <strtol+0x38>
		s++;
  800b97:	83 c2 01             	add    $0x1,%edx
  800b9a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800ba1:	eb 15                	jmp    800bb8 <strtol+0x4d>
	else if (*s == '-')
  800ba3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800baa:	3c 2d                	cmp    $0x2d,%al
  800bac:	75 0a                	jne    800bb8 <strtol+0x4d>
		s++, neg = 1;
  800bae:	83 c2 01             	add    $0x1,%edx
  800bb1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800bb8:	85 db                	test   %ebx,%ebx
  800bba:	0f 94 c0             	sete   %al
  800bbd:	74 05                	je     800bc4 <strtol+0x59>
  800bbf:	83 fb 10             	cmp    $0x10,%ebx
  800bc2:	75 18                	jne    800bdc <strtol+0x71>
  800bc4:	80 3a 30             	cmpb   $0x30,(%edx)
  800bc7:	75 13                	jne    800bdc <strtol+0x71>
  800bc9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800bcd:	8d 76 00             	lea    0x0(%esi),%esi
  800bd0:	75 0a                	jne    800bdc <strtol+0x71>
		s += 2, base = 16;
  800bd2:	83 c2 02             	add    $0x2,%edx
  800bd5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800bda:	eb 15                	jmp    800bf1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800bdc:	84 c0                	test   %al,%al
  800bde:	66 90                	xchg   %ax,%ax
  800be0:	74 0f                	je     800bf1 <strtol+0x86>
  800be2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800be7:	80 3a 30             	cmpb   $0x30,(%edx)
  800bea:	75 05                	jne    800bf1 <strtol+0x86>
		s++, base = 8;
  800bec:	83 c2 01             	add    $0x1,%edx
  800bef:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800bf1:	b8 00 00 00 00       	mov    $0x0,%eax
  800bf6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800bf8:	0f b6 0a             	movzbl (%edx),%ecx
  800bfb:	89 cf                	mov    %ecx,%edi
  800bfd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800c00:	80 fb 09             	cmp    $0x9,%bl
  800c03:	77 08                	ja     800c0d <strtol+0xa2>
			dig = *s - '0';
  800c05:	0f be c9             	movsbl %cl,%ecx
  800c08:	83 e9 30             	sub    $0x30,%ecx
  800c0b:	eb 1e                	jmp    800c2b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800c0d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800c10:	80 fb 19             	cmp    $0x19,%bl
  800c13:	77 08                	ja     800c1d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800c15:	0f be c9             	movsbl %cl,%ecx
  800c18:	83 e9 57             	sub    $0x57,%ecx
  800c1b:	eb 0e                	jmp    800c2b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800c1d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800c20:	80 fb 19             	cmp    $0x19,%bl
  800c23:	77 15                	ja     800c3a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800c25:	0f be c9             	movsbl %cl,%ecx
  800c28:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800c2b:	39 f1                	cmp    %esi,%ecx
  800c2d:	7d 0b                	jge    800c3a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800c2f:	83 c2 01             	add    $0x1,%edx
  800c32:	0f af c6             	imul   %esi,%eax
  800c35:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800c38:	eb be                	jmp    800bf8 <strtol+0x8d>
  800c3a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800c3c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800c40:	74 05                	je     800c47 <strtol+0xdc>
		*endptr = (char *) s;
  800c42:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800c45:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800c47:	89 ca                	mov    %ecx,%edx
  800c49:	f7 da                	neg    %edx
  800c4b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800c4f:	0f 45 c2             	cmovne %edx,%eax
}
  800c52:	83 c4 04             	add    $0x4,%esp
  800c55:	5b                   	pop    %ebx
  800c56:	5e                   	pop    %esi
  800c57:	5f                   	pop    %edi
  800c58:	5d                   	pop    %ebp
  800c59:	c3                   	ret    
	...

00800c5c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800c5c:	55                   	push   %ebp
  800c5d:	89 e5                	mov    %esp,%ebp
  800c5f:	83 ec 0c             	sub    $0xc,%esp
  800c62:	89 1c 24             	mov    %ebx,(%esp)
  800c65:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c69:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800c6d:	ba 00 00 00 00       	mov    $0x0,%edx
  800c72:	b8 01 00 00 00       	mov    $0x1,%eax
  800c77:	89 d1                	mov    %edx,%ecx
  800c79:	89 d3                	mov    %edx,%ebx
  800c7b:	89 d7                	mov    %edx,%edi
  800c7d:	89 d6                	mov    %edx,%esi
  800c7f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800c81:	8b 1c 24             	mov    (%esp),%ebx
  800c84:	8b 74 24 04          	mov    0x4(%esp),%esi
  800c88:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800c8c:	89 ec                	mov    %ebp,%esp
  800c8e:	5d                   	pop    %ebp
  800c8f:	c3                   	ret    

00800c90 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800c90:	55                   	push   %ebp
  800c91:	89 e5                	mov    %esp,%ebp
  800c93:	83 ec 0c             	sub    $0xc,%esp
  800c96:	89 1c 24             	mov    %ebx,(%esp)
  800c99:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c9d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ca1:	b8 00 00 00 00       	mov    $0x0,%eax
  800ca6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ca9:	8b 55 08             	mov    0x8(%ebp),%edx
  800cac:	89 c3                	mov    %eax,%ebx
  800cae:	89 c7                	mov    %eax,%edi
  800cb0:	89 c6                	mov    %eax,%esi
  800cb2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800cb4:	8b 1c 24             	mov    (%esp),%ebx
  800cb7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cbb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800cbf:	89 ec                	mov    %ebp,%esp
  800cc1:	5d                   	pop    %ebp
  800cc2:	c3                   	ret    

00800cc3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800cc3:	55                   	push   %ebp
  800cc4:	89 e5                	mov    %esp,%ebp
  800cc6:	83 ec 0c             	sub    $0xc,%esp
  800cc9:	89 1c 24             	mov    %ebx,(%esp)
  800ccc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800cd0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800cd4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800cd9:	b8 10 00 00 00       	mov    $0x10,%eax
  800cde:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ce1:	8b 55 08             	mov    0x8(%ebp),%edx
  800ce4:	89 df                	mov    %ebx,%edi
  800ce6:	89 de                	mov    %ebx,%esi
  800ce8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800cea:	8b 1c 24             	mov    (%esp),%ebx
  800ced:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cf1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800cf5:	89 ec                	mov    %ebp,%esp
  800cf7:	5d                   	pop    %ebp
  800cf8:	c3                   	ret    

00800cf9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800cf9:	55                   	push   %ebp
  800cfa:	89 e5                	mov    %esp,%ebp
  800cfc:	83 ec 0c             	sub    $0xc,%esp
  800cff:	89 1c 24             	mov    %ebx,(%esp)
  800d02:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d06:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d0a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800d0f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800d14:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d17:	8b 55 08             	mov    0x8(%ebp),%edx
  800d1a:	89 df                	mov    %ebx,%edi
  800d1c:	89 de                	mov    %ebx,%esi
  800d1e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800d20:	8b 1c 24             	mov    (%esp),%ebx
  800d23:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d27:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d2b:	89 ec                	mov    %ebp,%esp
  800d2d:	5d                   	pop    %ebp
  800d2e:	c3                   	ret    

00800d2f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800d2f:	55                   	push   %ebp
  800d30:	89 e5                	mov    %esp,%ebp
  800d32:	83 ec 0c             	sub    $0xc,%esp
  800d35:	89 1c 24             	mov    %ebx,(%esp)
  800d38:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d3c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d40:	ba 00 00 00 00       	mov    $0x0,%edx
  800d45:	b8 0e 00 00 00       	mov    $0xe,%eax
  800d4a:	89 d1                	mov    %edx,%ecx
  800d4c:	89 d3                	mov    %edx,%ebx
  800d4e:	89 d7                	mov    %edx,%edi
  800d50:	89 d6                	mov    %edx,%esi
  800d52:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800d54:	8b 1c 24             	mov    (%esp),%ebx
  800d57:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d5b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d5f:	89 ec                	mov    %ebp,%esp
  800d61:	5d                   	pop    %ebp
  800d62:	c3                   	ret    

00800d63 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800d63:	55                   	push   %ebp
  800d64:	89 e5                	mov    %esp,%ebp
  800d66:	83 ec 38             	sub    $0x38,%esp
  800d69:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800d6c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800d6f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d72:	b9 00 00 00 00       	mov    $0x0,%ecx
  800d77:	b8 0d 00 00 00       	mov    $0xd,%eax
  800d7c:	8b 55 08             	mov    0x8(%ebp),%edx
  800d7f:	89 cb                	mov    %ecx,%ebx
  800d81:	89 cf                	mov    %ecx,%edi
  800d83:	89 ce                	mov    %ecx,%esi
  800d85:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800d87:	85 c0                	test   %eax,%eax
  800d89:	7e 28                	jle    800db3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800d8b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800d8f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800d96:	00 
  800d97:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800d9e:	00 
  800d9f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800da6:	00 
  800da7:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800dae:	e8 d1 1b 00 00       	call   802984 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800db3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800db6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800db9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800dbc:	89 ec                	mov    %ebp,%esp
  800dbe:	5d                   	pop    %ebp
  800dbf:	c3                   	ret    

00800dc0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800dc0:	55                   	push   %ebp
  800dc1:	89 e5                	mov    %esp,%ebp
  800dc3:	83 ec 38             	sub    $0x38,%esp
  800dc6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800dc9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800dcc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dcf:	be 00 00 00 00       	mov    $0x0,%esi
  800dd4:	b8 0c 00 00 00       	mov    $0xc,%eax
  800dd9:	8b 7d 14             	mov    0x14(%ebp),%edi
  800ddc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800ddf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800de2:	8b 55 08             	mov    0x8(%ebp),%edx
  800de5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800de7:	85 c0                	test   %eax,%eax
  800de9:	7e 28                	jle    800e13 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800deb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800def:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800df6:	00 
  800df7:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800dfe:	00 
  800dff:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e06:	00 
  800e07:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800e0e:	e8 71 1b 00 00       	call   802984 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800e13:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e16:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e19:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e1c:	89 ec                	mov    %ebp,%esp
  800e1e:	5d                   	pop    %ebp
  800e1f:	c3                   	ret    

00800e20 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800e20:	55                   	push   %ebp
  800e21:	89 e5                	mov    %esp,%ebp
  800e23:	83 ec 38             	sub    $0x38,%esp
  800e26:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e29:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e2c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e2f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e34:	b8 0a 00 00 00       	mov    $0xa,%eax
  800e39:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e3c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e3f:	89 df                	mov    %ebx,%edi
  800e41:	89 de                	mov    %ebx,%esi
  800e43:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800e45:	85 c0                	test   %eax,%eax
  800e47:	7e 28                	jle    800e71 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800e49:	89 44 24 10          	mov    %eax,0x10(%esp)
  800e4d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800e54:	00 
  800e55:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800e5c:	00 
  800e5d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e64:	00 
  800e65:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800e6c:	e8 13 1b 00 00       	call   802984 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800e71:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e74:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e77:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e7a:	89 ec                	mov    %ebp,%esp
  800e7c:	5d                   	pop    %ebp
  800e7d:	c3                   	ret    

00800e7e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800e7e:	55                   	push   %ebp
  800e7f:	89 e5                	mov    %esp,%ebp
  800e81:	83 ec 38             	sub    $0x38,%esp
  800e84:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e87:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e8a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e8d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e92:	b8 09 00 00 00       	mov    $0x9,%eax
  800e97:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e9a:	8b 55 08             	mov    0x8(%ebp),%edx
  800e9d:	89 df                	mov    %ebx,%edi
  800e9f:	89 de                	mov    %ebx,%esi
  800ea1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800ea3:	85 c0                	test   %eax,%eax
  800ea5:	7e 28                	jle    800ecf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800ea7:	89 44 24 10          	mov    %eax,0x10(%esp)
  800eab:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800eb2:	00 
  800eb3:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800eba:	00 
  800ebb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ec2:	00 
  800ec3:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800eca:	e8 b5 1a 00 00       	call   802984 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800ecf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ed2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ed5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ed8:	89 ec                	mov    %ebp,%esp
  800eda:	5d                   	pop    %ebp
  800edb:	c3                   	ret    

00800edc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800edc:	55                   	push   %ebp
  800edd:	89 e5                	mov    %esp,%ebp
  800edf:	83 ec 38             	sub    $0x38,%esp
  800ee2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ee5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800ee8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eeb:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ef0:	b8 08 00 00 00       	mov    $0x8,%eax
  800ef5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ef8:	8b 55 08             	mov    0x8(%ebp),%edx
  800efb:	89 df                	mov    %ebx,%edi
  800efd:	89 de                	mov    %ebx,%esi
  800eff:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f01:	85 c0                	test   %eax,%eax
  800f03:	7e 28                	jle    800f2d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f05:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f09:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  800f10:	00 
  800f11:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800f18:	00 
  800f19:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f20:	00 
  800f21:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800f28:	e8 57 1a 00 00       	call   802984 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800f2d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f30:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f33:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f36:	89 ec                	mov    %ebp,%esp
  800f38:	5d                   	pop    %ebp
  800f39:	c3                   	ret    

00800f3a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  800f3a:	55                   	push   %ebp
  800f3b:	89 e5                	mov    %esp,%ebp
  800f3d:	83 ec 38             	sub    $0x38,%esp
  800f40:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f43:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f46:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f49:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f4e:	b8 06 00 00 00       	mov    $0x6,%eax
  800f53:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f56:	8b 55 08             	mov    0x8(%ebp),%edx
  800f59:	89 df                	mov    %ebx,%edi
  800f5b:	89 de                	mov    %ebx,%esi
  800f5d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f5f:	85 c0                	test   %eax,%eax
  800f61:	7e 28                	jle    800f8b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f63:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f67:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  800f6e:	00 
  800f6f:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800f76:	00 
  800f77:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f7e:	00 
  800f7f:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800f86:	e8 f9 19 00 00       	call   802984 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  800f8b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f8e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f91:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f94:	89 ec                	mov    %ebp,%esp
  800f96:	5d                   	pop    %ebp
  800f97:	c3                   	ret    

00800f98 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  800f98:	55                   	push   %ebp
  800f99:	89 e5                	mov    %esp,%ebp
  800f9b:	83 ec 38             	sub    $0x38,%esp
  800f9e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fa1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fa4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fa7:	b8 05 00 00 00       	mov    $0x5,%eax
  800fac:	8b 75 18             	mov    0x18(%ebp),%esi
  800faf:	8b 7d 14             	mov    0x14(%ebp),%edi
  800fb2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800fb5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fb8:	8b 55 08             	mov    0x8(%ebp),%edx
  800fbb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fbd:	85 c0                	test   %eax,%eax
  800fbf:	7e 28                	jle    800fe9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fc1:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fc5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  800fcc:	00 
  800fcd:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  800fd4:	00 
  800fd5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fdc:	00 
  800fdd:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  800fe4:	e8 9b 19 00 00       	call   802984 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800fe9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fec:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fef:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ff2:	89 ec                	mov    %ebp,%esp
  800ff4:	5d                   	pop    %ebp
  800ff5:	c3                   	ret    

00800ff6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800ff6:	55                   	push   %ebp
  800ff7:	89 e5                	mov    %esp,%ebp
  800ff9:	83 ec 38             	sub    $0x38,%esp
  800ffc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fff:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801002:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801005:	be 00 00 00 00       	mov    $0x0,%esi
  80100a:	b8 04 00 00 00       	mov    $0x4,%eax
  80100f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801012:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801015:	8b 55 08             	mov    0x8(%ebp),%edx
  801018:	89 f7                	mov    %esi,%edi
  80101a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80101c:	85 c0                	test   %eax,%eax
  80101e:	7e 28                	jle    801048 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801020:	89 44 24 10          	mov    %eax,0x10(%esp)
  801024:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80102b:	00 
  80102c:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  801033:	00 
  801034:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80103b:	00 
  80103c:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  801043:	e8 3c 19 00 00       	call   802984 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801048:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80104b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80104e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801051:	89 ec                	mov    %ebp,%esp
  801053:	5d                   	pop    %ebp
  801054:	c3                   	ret    

00801055 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801055:	55                   	push   %ebp
  801056:	89 e5                	mov    %esp,%ebp
  801058:	83 ec 0c             	sub    $0xc,%esp
  80105b:	89 1c 24             	mov    %ebx,(%esp)
  80105e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801062:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801066:	ba 00 00 00 00       	mov    $0x0,%edx
  80106b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801070:	89 d1                	mov    %edx,%ecx
  801072:	89 d3                	mov    %edx,%ebx
  801074:	89 d7                	mov    %edx,%edi
  801076:	89 d6                	mov    %edx,%esi
  801078:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80107a:	8b 1c 24             	mov    (%esp),%ebx
  80107d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801081:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801085:	89 ec                	mov    %ebp,%esp
  801087:	5d                   	pop    %ebp
  801088:	c3                   	ret    

00801089 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801089:	55                   	push   %ebp
  80108a:	89 e5                	mov    %esp,%ebp
  80108c:	83 ec 0c             	sub    $0xc,%esp
  80108f:	89 1c 24             	mov    %ebx,(%esp)
  801092:	89 74 24 04          	mov    %esi,0x4(%esp)
  801096:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80109a:	ba 00 00 00 00       	mov    $0x0,%edx
  80109f:	b8 02 00 00 00       	mov    $0x2,%eax
  8010a4:	89 d1                	mov    %edx,%ecx
  8010a6:	89 d3                	mov    %edx,%ebx
  8010a8:	89 d7                	mov    %edx,%edi
  8010aa:	89 d6                	mov    %edx,%esi
  8010ac:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8010ae:	8b 1c 24             	mov    (%esp),%ebx
  8010b1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8010b5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8010b9:	89 ec                	mov    %ebp,%esp
  8010bb:	5d                   	pop    %ebp
  8010bc:	c3                   	ret    

008010bd <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8010bd:	55                   	push   %ebp
  8010be:	89 e5                	mov    %esp,%ebp
  8010c0:	83 ec 38             	sub    $0x38,%esp
  8010c3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010c6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010c9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010cc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8010d1:	b8 03 00 00 00       	mov    $0x3,%eax
  8010d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8010d9:	89 cb                	mov    %ecx,%ebx
  8010db:	89 cf                	mov    %ecx,%edi
  8010dd:	89 ce                	mov    %ecx,%esi
  8010df:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010e1:	85 c0                	test   %eax,%eax
  8010e3:	7e 28                	jle    80110d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010e5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010e9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8010f0:	00 
  8010f1:	c7 44 24 08 8b 30 80 	movl   $0x80308b,0x8(%esp)
  8010f8:	00 
  8010f9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801100:	00 
  801101:	c7 04 24 a8 30 80 00 	movl   $0x8030a8,(%esp)
  801108:	e8 77 18 00 00       	call   802984 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80110d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801110:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801113:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801116:	89 ec                	mov    %ebp,%esp
  801118:	5d                   	pop    %ebp
  801119:	c3                   	ret    
  80111a:	00 00                	add    %al,(%eax)
  80111c:	00 00                	add    %al,(%eax)
	...

00801120 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801120:	55                   	push   %ebp
  801121:	89 e5                	mov    %esp,%ebp
  801123:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801126:	c7 44 24 08 b6 30 80 	movl   $0x8030b6,0x8(%esp)
  80112d:	00 
  80112e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801135:	00 
  801136:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  80113d:	e8 42 18 00 00       	call   802984 <_panic>

00801142 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801142:	55                   	push   %ebp
  801143:	89 e5                	mov    %esp,%ebp
  801145:	57                   	push   %edi
  801146:	56                   	push   %esi
  801147:	53                   	push   %ebx
  801148:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  80114b:	c7 04 24 ac 13 80 00 	movl   $0x8013ac,(%esp)
  801152:	e8 91 18 00 00       	call   8029e8 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801157:	ba 07 00 00 00       	mov    $0x7,%edx
  80115c:	89 d0                	mov    %edx,%eax
  80115e:	cd 30                	int    $0x30
  801160:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801163:	85 c0                	test   %eax,%eax
  801165:	79 20                	jns    801187 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801167:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80116b:	c7 44 24 08 3c 31 80 	movl   $0x80313c,0x8(%esp)
  801172:	00 
  801173:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  80117a:	00 
  80117b:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  801182:	e8 fd 17 00 00       	call   802984 <_panic>
    } else if (childId>0) {
  801187:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80118b:	0f 8e f3 01 00 00    	jle    801384 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801191:	c7 44 24 04 58 2a 80 	movl   $0x802a58,0x4(%esp)
  801198:	00 
  801199:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80119c:	89 04 24             	mov    %eax,(%esp)
  80119f:	e8 7c fc ff ff       	call   800e20 <sys_env_set_pgfault_upcall>
  8011a4:	85 c0                	test   %eax,%eax
  8011a6:	74 20                	je     8011c8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  8011a8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8011ac:	c7 44 24 08 60 31 80 	movl   $0x803160,0x8(%esp)
  8011b3:	00 
  8011b4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  8011bb:	00 
  8011bc:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  8011c3:	e8 bc 17 00 00       	call   802984 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  8011c8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8011cf:	00 
  8011d0:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  8011d7:	ee 
  8011d8:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8011db:	89 04 24             	mov    %eax,(%esp)
  8011de:	e8 13 fe ff ff       	call   800ff6 <sys_page_alloc>
  8011e3:	85 c0                	test   %eax,%eax
  8011e5:	79 20                	jns    801207 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  8011e7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8011eb:	c7 44 24 08 90 31 80 	movl   $0x803190,0x8(%esp)
  8011f2:	00 
  8011f3:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  8011fa:	00 
  8011fb:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  801202:	e8 7d 17 00 00       	call   802984 <_panic>
  801207:	be 00 00 80 00       	mov    $0x800000,%esi
  80120c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801211:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801216:	89 f0                	mov    %esi,%eax
  801218:	c1 e8 16             	shr    $0x16,%eax
  80121b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80121e:	a8 01                	test   $0x1,%al
  801220:	0f 84 13 01 00 00    	je     801339 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801226:	89 f0                	mov    %esi,%eax
  801228:	c1 e8 0c             	shr    $0xc,%eax
  80122b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801232:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801235:	25 07 0e 00 00       	and    $0xe07,%eax
  80123a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80123d:	e8 47 fe ff ff       	call   801089 <sys_getenvid>
  801242:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801245:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801249:	0f 84 ea 00 00 00    	je     801339 <fork+0x1f7>
  80124f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801256:	0f 84 9d 00 00 00    	je     8012f9 <fork+0x1b7>
  80125c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801263:	0f 85 90 00 00 00    	jne    8012f9 <fork+0x1b7>
    perm    &= (~PTE_W);
  801269:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80126c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  80126f:	80 cc 08             	or     $0x8,%ah
  801272:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801275:	89 75 e0             	mov    %esi,-0x20(%ebp)
  801278:	89 44 24 10          	mov    %eax,0x10(%esp)
  80127c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801280:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801283:	89 44 24 08          	mov    %eax,0x8(%esp)
  801287:	89 74 24 04          	mov    %esi,0x4(%esp)
  80128b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80128e:	89 04 24             	mov    %eax,(%esp)
  801291:	e8 02 fd ff ff       	call   800f98 <sys_page_map>
  801296:	85 c0                	test   %eax,%eax
  801298:	79 1b                	jns    8012b5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80129a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80129e:	89 74 24 08          	mov    %esi,0x8(%esp)
  8012a2:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012a5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012a9:	c7 04 24 b8 31 80 00 	movl   $0x8031b8,(%esp)
  8012b0:	e8 10 ef ff ff       	call   8001c5 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  8012b5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8012b8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012bc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012bf:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8012c3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012c6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8012ca:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012cd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012d1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8012d4:	89 04 24             	mov    %eax,(%esp)
  8012d7:	e8 bc fc ff ff       	call   800f98 <sys_page_map>
  8012dc:	85 c0                	test   %eax,%eax
  8012de:	79 59                	jns    801339 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  8012e0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8012e4:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012eb:	c7 04 24 f8 31 80 00 	movl   $0x8031f8,(%esp)
  8012f2:	e8 ce ee ff ff       	call   8001c5 <cprintf>
  8012f7:	eb 40                	jmp    801339 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8012f9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012fc:	89 44 24 10          	mov    %eax,0x10(%esp)
  801300:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801304:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801307:	89 44 24 08          	mov    %eax,0x8(%esp)
  80130b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80130f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801312:	89 04 24             	mov    %eax,(%esp)
  801315:	e8 7e fc ff ff       	call   800f98 <sys_page_map>
  80131a:	85 c0                	test   %eax,%eax
  80131c:	79 1b                	jns    801339 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80131e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801322:	89 74 24 08          	mov    %esi,0x8(%esp)
  801326:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801329:	89 44 24 04          	mov    %eax,0x4(%esp)
  80132d:	c7 04 24 b8 31 80 00 	movl   $0x8031b8,(%esp)
  801334:	e8 8c ee ff ff       	call   8001c5 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801339:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80133f:	89 de                	mov    %ebx,%esi
  801341:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801347:	0f 85 c9 fe ff ff    	jne    801216 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  80134d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801354:	00 
  801355:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801358:	89 04 24             	mov    %eax,(%esp)
  80135b:	e8 7c fb ff ff       	call   800edc <sys_env_set_status>
  801360:	85 c0                	test   %eax,%eax
  801362:	79 3d                	jns    8013a1 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801364:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801368:	c7 44 24 08 2c 32 80 	movl   $0x80322c,0x8(%esp)
  80136f:	00 
  801370:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  801377:	00 
  801378:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  80137f:	e8 00 16 00 00       	call   802984 <_panic>
    } else if (childId==0) {
  801384:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801388:	75 17                	jne    8013a1 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80138a:	e8 fa fc ff ff       	call   801089 <sys_getenvid>
  80138f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801394:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801397:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80139c:	a3 74 70 80 00       	mov    %eax,0x807074
    }
    return childId;
}
  8013a1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8013a4:	83 c4 3c             	add    $0x3c,%esp
  8013a7:	5b                   	pop    %ebx
  8013a8:	5e                   	pop    %esi
  8013a9:	5f                   	pop    %edi
  8013aa:	5d                   	pop    %ebp
  8013ab:	c3                   	ret    

008013ac <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8013ac:	55                   	push   %ebp
  8013ad:	89 e5                	mov    %esp,%ebp
  8013af:	57                   	push   %edi
  8013b0:	56                   	push   %esi
  8013b1:	53                   	push   %ebx
  8013b2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  8013b5:	8b 45 08             	mov    0x8(%ebp),%eax
  8013b8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  8013ba:	8b 50 04             	mov    0x4(%eax),%edx
  8013bd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  8013c0:	89 fe                	mov    %edi,%esi
  8013c2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  8013c8:	e8 bc fc ff ff       	call   801089 <sys_getenvid>
  8013cd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  8013cf:	89 f2                	mov    %esi,%edx
  8013d1:	89 f0                	mov    %esi,%eax
  8013d3:	c1 e8 16             	shr    $0x16,%eax
  8013d6:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8013dd:	a8 01                	test   $0x1,%al
  8013df:	74 3e                	je     80141f <pgfault+0x73>
  8013e1:	c1 ea 0c             	shr    $0xc,%edx
  8013e4:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8013eb:	a8 01                	test   $0x1,%al
  8013ed:	74 30                	je     80141f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  8013ef:	c1 ef 0c             	shr    $0xc,%edi
  8013f2:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  8013f9:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  8013ff:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801402:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801406:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80140d:	00 
  80140e:	89 1c 24             	mov    %ebx,(%esp)
  801411:	e8 e0 fb ff ff       	call   800ff6 <sys_page_alloc>
  801416:	85 c0                	test   %eax,%eax
  801418:	74 46                	je     801460 <pgfault+0xb4>
  80141a:	e9 cd 00 00 00       	jmp    8014ec <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80141f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801422:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801426:	8b 55 08             	mov    0x8(%ebp),%edx
  801429:	8b 42 28             	mov    0x28(%edx),%eax
  80142c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801430:	89 74 24 04          	mov    %esi,0x4(%esp)
  801434:	c7 04 24 4c 32 80 00 	movl   $0x80324c,(%esp)
  80143b:	e8 85 ed ff ff       	call   8001c5 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801440:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801444:	c7 44 24 08 d7 30 80 	movl   $0x8030d7,0x8(%esp)
  80144b:	00 
  80144c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801453:	00 
  801454:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  80145b:	e8 24 15 00 00       	call   802984 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801460:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801467:	00 
  801468:	89 74 24 04          	mov    %esi,0x4(%esp)
  80146c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  801473:	e8 dd f5 ff ff       	call   800a55 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  801478:	89 7c 24 10          	mov    %edi,0x10(%esp)
  80147c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801480:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801484:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80148b:	00 
  80148c:	89 1c 24             	mov    %ebx,(%esp)
  80148f:	e8 04 fb ff ff       	call   800f98 <sys_page_map>
  801494:	85 c0                	test   %eax,%eax
  801496:	74 20                	je     8014b8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801498:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80149c:	c7 44 24 08 e9 30 80 	movl   $0x8030e9,0x8(%esp)
  8014a3:	00 
  8014a4:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  8014ab:	00 
  8014ac:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  8014b3:	e8 cc 14 00 00       	call   802984 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  8014b8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8014bf:	00 
  8014c0:	89 1c 24             	mov    %ebx,(%esp)
  8014c3:	e8 72 fa ff ff       	call   800f3a <sys_page_unmap>
  8014c8:	85 c0                	test   %eax,%eax
  8014ca:	74 40                	je     80150c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  8014cc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014d0:	c7 44 24 08 04 31 80 	movl   $0x803104,0x8(%esp)
  8014d7:	00 
  8014d8:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  8014df:	00 
  8014e0:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  8014e7:	e8 98 14 00 00       	call   802984 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  8014ec:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014f0:	c7 44 24 08 21 31 80 	movl   $0x803121,0x8(%esp)
  8014f7:	00 
  8014f8:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  8014ff:	00 
  801500:	c7 04 24 cc 30 80 00 	movl   $0x8030cc,(%esp)
  801507:	e8 78 14 00 00       	call   802984 <_panic>
}
  80150c:	83 c4 3c             	add    $0x3c,%esp
  80150f:	5b                   	pop    %ebx
  801510:	5e                   	pop    %esi
  801511:	5f                   	pop    %edi
  801512:	5d                   	pop    %ebp
  801513:	c3                   	ret    
	...

00801520 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  801520:	55                   	push   %ebp
  801521:	89 e5                	mov    %esp,%ebp
  801523:	57                   	push   %edi
  801524:	56                   	push   %esi
  801525:	53                   	push   %ebx
  801526:	83 ec 2c             	sub    $0x2c,%esp
  801529:	8b 75 08             	mov    0x8(%ebp),%esi
  80152c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80152f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  801532:	85 db                	test   %ebx,%ebx
  801534:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  801539:	0f 45 c3             	cmovne %ebx,%eax
  80153c:	8b 55 14             	mov    0x14(%ebp),%edx
  80153f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  801543:	89 44 24 08          	mov    %eax,0x8(%esp)
  801547:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80154b:	89 34 24             	mov    %esi,(%esp)
  80154e:	e8 6d f8 ff ff       	call   800dc0 <sys_ipc_try_send>
  801553:	83 f8 f9             	cmp    $0xfffffff9,%eax
  801556:	75 0a                	jne    801562 <ipc_send+0x42>
      sys_yield();
  801558:	e8 f8 fa ff ff       	call   801055 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80155d:	8d 76 00             	lea    0x0(%esi),%esi
  801560:	eb d0                	jmp    801532 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  801562:	85 c0                	test   %eax,%eax
  801564:	79 24                	jns    80158a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  801566:	89 44 24 10          	mov    %eax,0x10(%esp)
  80156a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80156e:	c7 44 24 08 78 32 80 	movl   $0x803278,0x8(%esp)
  801575:	00 
  801576:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80157d:	00 
  80157e:	c7 04 24 9c 32 80 00 	movl   $0x80329c,(%esp)
  801585:	e8 fa 13 00 00       	call   802984 <_panic>
    else
      return;
  }
}
  80158a:	83 c4 2c             	add    $0x2c,%esp
  80158d:	5b                   	pop    %ebx
  80158e:	5e                   	pop    %esi
  80158f:	5f                   	pop    %edi
  801590:	5d                   	pop    %ebp
  801591:	c3                   	ret    

00801592 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  801592:	55                   	push   %ebp
  801593:	89 e5                	mov    %esp,%ebp
  801595:	56                   	push   %esi
  801596:	53                   	push   %ebx
  801597:	83 ec 10             	sub    $0x10,%esp
  80159a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80159d:	8b 45 0c             	mov    0xc(%ebp),%eax
  8015a0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  8015a3:	85 c0                	test   %eax,%eax
  8015a5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8015aa:	0f 44 c2             	cmove  %edx,%eax
  8015ad:	89 04 24             	mov    %eax,(%esp)
  8015b0:	e8 ae f7 ff ff       	call   800d63 <sys_ipc_recv>
  8015b5:	85 c0                	test   %eax,%eax
  8015b7:	78 24                	js     8015dd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  8015b9:	85 db                	test   %ebx,%ebx
  8015bb:	74 0a                	je     8015c7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  8015bd:	a1 74 70 80 00       	mov    0x807074,%eax
  8015c2:	8b 40 74             	mov    0x74(%eax),%eax
  8015c5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  8015c7:	85 f6                	test   %esi,%esi
  8015c9:	74 0a                	je     8015d5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  8015cb:	a1 74 70 80 00       	mov    0x807074,%eax
  8015d0:	8b 40 78             	mov    0x78(%eax),%eax
  8015d3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8015d5:	a1 74 70 80 00       	mov    0x807074,%eax
  8015da:	8b 40 70             	mov    0x70(%eax),%eax
}
  8015dd:	83 c4 10             	add    $0x10,%esp
  8015e0:	5b                   	pop    %ebx
  8015e1:	5e                   	pop    %esi
  8015e2:	5d                   	pop    %ebp
  8015e3:	c3                   	ret    
	...

008015f0 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  8015f0:	55                   	push   %ebp
  8015f1:	89 e5                	mov    %esp,%ebp
  8015f3:	8b 45 08             	mov    0x8(%ebp),%eax
  8015f6:	05 00 00 00 30       	add    $0x30000000,%eax
  8015fb:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  8015fe:	5d                   	pop    %ebp
  8015ff:	c3                   	ret    

00801600 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801600:	55                   	push   %ebp
  801601:	89 e5                	mov    %esp,%ebp
  801603:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801606:	8b 45 08             	mov    0x8(%ebp),%eax
  801609:	89 04 24             	mov    %eax,(%esp)
  80160c:	e8 df ff ff ff       	call   8015f0 <fd2num>
  801611:	05 20 00 0d 00       	add    $0xd0020,%eax
  801616:	c1 e0 0c             	shl    $0xc,%eax
}
  801619:	c9                   	leave  
  80161a:	c3                   	ret    

0080161b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80161b:	55                   	push   %ebp
  80161c:	89 e5                	mov    %esp,%ebp
  80161e:	57                   	push   %edi
  80161f:	56                   	push   %esi
  801620:	53                   	push   %ebx
  801621:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801624:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801629:	a8 01                	test   $0x1,%al
  80162b:	74 36                	je     801663 <fd_alloc+0x48>
  80162d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801632:	a8 01                	test   $0x1,%al
  801634:	74 2d                	je     801663 <fd_alloc+0x48>
  801636:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80163b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801640:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801645:	89 c3                	mov    %eax,%ebx
  801647:	89 c2                	mov    %eax,%edx
  801649:	c1 ea 16             	shr    $0x16,%edx
  80164c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80164f:	f6 c2 01             	test   $0x1,%dl
  801652:	74 14                	je     801668 <fd_alloc+0x4d>
  801654:	89 c2                	mov    %eax,%edx
  801656:	c1 ea 0c             	shr    $0xc,%edx
  801659:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80165c:	f6 c2 01             	test   $0x1,%dl
  80165f:	75 10                	jne    801671 <fd_alloc+0x56>
  801661:	eb 05                	jmp    801668 <fd_alloc+0x4d>
  801663:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801668:	89 1f                	mov    %ebx,(%edi)
  80166a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80166f:	eb 17                	jmp    801688 <fd_alloc+0x6d>
  801671:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801676:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80167b:	75 c8                	jne    801645 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80167d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801683:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801688:	5b                   	pop    %ebx
  801689:	5e                   	pop    %esi
  80168a:	5f                   	pop    %edi
  80168b:	5d                   	pop    %ebp
  80168c:	c3                   	ret    

0080168d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80168d:	55                   	push   %ebp
  80168e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801690:	8b 45 08             	mov    0x8(%ebp),%eax
  801693:	83 f8 1f             	cmp    $0x1f,%eax
  801696:	77 36                	ja     8016ce <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801698:	05 00 00 0d 00       	add    $0xd0000,%eax
  80169d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8016a0:	89 c2                	mov    %eax,%edx
  8016a2:	c1 ea 16             	shr    $0x16,%edx
  8016a5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8016ac:	f6 c2 01             	test   $0x1,%dl
  8016af:	74 1d                	je     8016ce <fd_lookup+0x41>
  8016b1:	89 c2                	mov    %eax,%edx
  8016b3:	c1 ea 0c             	shr    $0xc,%edx
  8016b6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8016bd:	f6 c2 01             	test   $0x1,%dl
  8016c0:	74 0c                	je     8016ce <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8016c2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8016c5:	89 02                	mov    %eax,(%edx)
  8016c7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8016cc:	eb 05                	jmp    8016d3 <fd_lookup+0x46>
  8016ce:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8016d3:	5d                   	pop    %ebp
  8016d4:	c3                   	ret    

008016d5 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  8016d5:	55                   	push   %ebp
  8016d6:	89 e5                	mov    %esp,%ebp
  8016d8:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8016db:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8016de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016e2:	8b 45 08             	mov    0x8(%ebp),%eax
  8016e5:	89 04 24             	mov    %eax,(%esp)
  8016e8:	e8 a0 ff ff ff       	call   80168d <fd_lookup>
  8016ed:	85 c0                	test   %eax,%eax
  8016ef:	78 0e                	js     8016ff <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  8016f1:	8b 45 fc             	mov    -0x4(%ebp),%eax
  8016f4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8016f7:	89 50 04             	mov    %edx,0x4(%eax)
  8016fa:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8016ff:	c9                   	leave  
  801700:	c3                   	ret    

00801701 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801701:	55                   	push   %ebp
  801702:	89 e5                	mov    %esp,%ebp
  801704:	56                   	push   %esi
  801705:	53                   	push   %ebx
  801706:	83 ec 10             	sub    $0x10,%esp
  801709:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80170c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80170f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801714:	b8 04 70 80 00       	mov    $0x807004,%eax
  801719:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80171f:	75 11                	jne    801732 <dev_lookup+0x31>
  801721:	eb 04                	jmp    801727 <dev_lookup+0x26>
  801723:	39 08                	cmp    %ecx,(%eax)
  801725:	75 10                	jne    801737 <dev_lookup+0x36>
			*dev = devtab[i];
  801727:	89 03                	mov    %eax,(%ebx)
  801729:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80172e:	66 90                	xchg   %ax,%ax
  801730:	eb 36                	jmp    801768 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801732:	be 24 33 80 00       	mov    $0x803324,%esi
  801737:	83 c2 01             	add    $0x1,%edx
  80173a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80173d:	85 c0                	test   %eax,%eax
  80173f:	75 e2                	jne    801723 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801741:	a1 74 70 80 00       	mov    0x807074,%eax
  801746:	8b 40 4c             	mov    0x4c(%eax),%eax
  801749:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80174d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801751:	c7 04 24 a8 32 80 00 	movl   $0x8032a8,(%esp)
  801758:	e8 68 ea ff ff       	call   8001c5 <cprintf>
	*dev = 0;
  80175d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801763:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801768:	83 c4 10             	add    $0x10,%esp
  80176b:	5b                   	pop    %ebx
  80176c:	5e                   	pop    %esi
  80176d:	5d                   	pop    %ebp
  80176e:	c3                   	ret    

0080176f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80176f:	55                   	push   %ebp
  801770:	89 e5                	mov    %esp,%ebp
  801772:	53                   	push   %ebx
  801773:	83 ec 24             	sub    $0x24,%esp
  801776:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801779:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80177c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801780:	8b 45 08             	mov    0x8(%ebp),%eax
  801783:	89 04 24             	mov    %eax,(%esp)
  801786:	e8 02 ff ff ff       	call   80168d <fd_lookup>
  80178b:	85 c0                	test   %eax,%eax
  80178d:	78 53                	js     8017e2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80178f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801792:	89 44 24 04          	mov    %eax,0x4(%esp)
  801796:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801799:	8b 00                	mov    (%eax),%eax
  80179b:	89 04 24             	mov    %eax,(%esp)
  80179e:	e8 5e ff ff ff       	call   801701 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017a3:	85 c0                	test   %eax,%eax
  8017a5:	78 3b                	js     8017e2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8017a7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8017ac:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8017af:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8017b3:	74 2d                	je     8017e2 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8017b5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8017b8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8017bf:	00 00 00 
	stat->st_isdir = 0;
  8017c2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8017c9:	00 00 00 
	stat->st_dev = dev;
  8017cc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8017cf:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8017d5:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8017d9:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8017dc:	89 14 24             	mov    %edx,(%esp)
  8017df:	ff 50 14             	call   *0x14(%eax)
}
  8017e2:	83 c4 24             	add    $0x24,%esp
  8017e5:	5b                   	pop    %ebx
  8017e6:	5d                   	pop    %ebp
  8017e7:	c3                   	ret    

008017e8 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  8017e8:	55                   	push   %ebp
  8017e9:	89 e5                	mov    %esp,%ebp
  8017eb:	53                   	push   %ebx
  8017ec:	83 ec 24             	sub    $0x24,%esp
  8017ef:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017f2:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8017f5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017f9:	89 1c 24             	mov    %ebx,(%esp)
  8017fc:	e8 8c fe ff ff       	call   80168d <fd_lookup>
  801801:	85 c0                	test   %eax,%eax
  801803:	78 5f                	js     801864 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801805:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801808:	89 44 24 04          	mov    %eax,0x4(%esp)
  80180c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80180f:	8b 00                	mov    (%eax),%eax
  801811:	89 04 24             	mov    %eax,(%esp)
  801814:	e8 e8 fe ff ff       	call   801701 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801819:	85 c0                	test   %eax,%eax
  80181b:	78 47                	js     801864 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80181d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801820:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801824:	75 23                	jne    801849 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801826:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80182b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80182e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801832:	89 44 24 04          	mov    %eax,0x4(%esp)
  801836:	c7 04 24 c8 32 80 00 	movl   $0x8032c8,(%esp)
  80183d:	e8 83 e9 ff ff       	call   8001c5 <cprintf>
  801842:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801847:	eb 1b                	jmp    801864 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801849:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80184c:	8b 48 18             	mov    0x18(%eax),%ecx
  80184f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801854:	85 c9                	test   %ecx,%ecx
  801856:	74 0c                	je     801864 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801858:	8b 45 0c             	mov    0xc(%ebp),%eax
  80185b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80185f:	89 14 24             	mov    %edx,(%esp)
  801862:	ff d1                	call   *%ecx
}
  801864:	83 c4 24             	add    $0x24,%esp
  801867:	5b                   	pop    %ebx
  801868:	5d                   	pop    %ebp
  801869:	c3                   	ret    

0080186a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80186a:	55                   	push   %ebp
  80186b:	89 e5                	mov    %esp,%ebp
  80186d:	53                   	push   %ebx
  80186e:	83 ec 24             	sub    $0x24,%esp
  801871:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801874:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801877:	89 44 24 04          	mov    %eax,0x4(%esp)
  80187b:	89 1c 24             	mov    %ebx,(%esp)
  80187e:	e8 0a fe ff ff       	call   80168d <fd_lookup>
  801883:	85 c0                	test   %eax,%eax
  801885:	78 66                	js     8018ed <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801887:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80188a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80188e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801891:	8b 00                	mov    (%eax),%eax
  801893:	89 04 24             	mov    %eax,(%esp)
  801896:	e8 66 fe ff ff       	call   801701 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80189b:	85 c0                	test   %eax,%eax
  80189d:	78 4e                	js     8018ed <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80189f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8018a2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8018a6:	75 23                	jne    8018cb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8018a8:	a1 74 70 80 00       	mov    0x807074,%eax
  8018ad:	8b 40 4c             	mov    0x4c(%eax),%eax
  8018b0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8018b4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018b8:	c7 04 24 e9 32 80 00 	movl   $0x8032e9,(%esp)
  8018bf:	e8 01 e9 ff ff       	call   8001c5 <cprintf>
  8018c4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8018c9:	eb 22                	jmp    8018ed <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8018cb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8018ce:	8b 48 0c             	mov    0xc(%eax),%ecx
  8018d1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8018d6:	85 c9                	test   %ecx,%ecx
  8018d8:	74 13                	je     8018ed <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8018da:	8b 45 10             	mov    0x10(%ebp),%eax
  8018dd:	89 44 24 08          	mov    %eax,0x8(%esp)
  8018e1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8018e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018e8:	89 14 24             	mov    %edx,(%esp)
  8018eb:	ff d1                	call   *%ecx
}
  8018ed:	83 c4 24             	add    $0x24,%esp
  8018f0:	5b                   	pop    %ebx
  8018f1:	5d                   	pop    %ebp
  8018f2:	c3                   	ret    

008018f3 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  8018f3:	55                   	push   %ebp
  8018f4:	89 e5                	mov    %esp,%ebp
  8018f6:	57                   	push   %edi
  8018f7:	56                   	push   %esi
  8018f8:	53                   	push   %ebx
  8018f9:	83 ec 2c             	sub    $0x2c,%esp
  8018fc:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8018ff:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801902:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801905:	89 44 24 04          	mov    %eax,0x4(%esp)
  801909:	89 1c 24             	mov    %ebx,(%esp)
  80190c:	e8 7c fd ff ff       	call   80168d <fd_lookup>
  801911:	85 c0                	test   %eax,%eax
  801913:	0f 88 b0 00 00 00    	js     8019c9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801919:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80191c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801920:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801923:	8b 00                	mov    (%eax),%eax
  801925:	89 04 24             	mov    %eax,(%esp)
  801928:	e8 d4 fd ff ff       	call   801701 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80192d:	85 c0                	test   %eax,%eax
  80192f:	0f 88 94 00 00 00    	js     8019c9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801935:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801938:	8b 40 08             	mov    0x8(%eax),%eax
  80193b:	83 e0 03             	and    $0x3,%eax
  80193e:	83 f8 01             	cmp    $0x1,%eax
  801941:	75 23                	jne    801966 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801943:	a1 74 70 80 00       	mov    0x807074,%eax
  801948:	8b 40 4c             	mov    0x4c(%eax),%eax
  80194b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80194f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801953:	c7 04 24 06 33 80 00 	movl   $0x803306,(%esp)
  80195a:	e8 66 e8 ff ff       	call   8001c5 <cprintf>
  80195f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801964:	eb 63                	jmp    8019c9 <read+0xd6>
	}
	if (!dev->dev_read)
  801966:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80196b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80196e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801972:	74 55                	je     8019c9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801974:	ba 00 00 00 00       	mov    $0x0,%edx
  801979:	bb 00 00 00 00       	mov    $0x0,%ebx
  80197e:	b8 00 00 00 00       	mov    $0x0,%eax
  801983:	85 f6                	test   %esi,%esi
  801985:	74 42                	je     8019c9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801987:	bf 00 10 00 00       	mov    $0x1000,%edi
  80198c:	89 f0                	mov    %esi,%eax
  80198e:	29 d0                	sub    %edx,%eax
  801990:	89 c1                	mov    %eax,%ecx
  801992:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801998:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80199d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8019a0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8019a4:	03 55 0c             	add    0xc(%ebp),%edx
  8019a7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8019ab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8019ae:	89 04 24             	mov    %eax,(%esp)
  8019b1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8019b4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8019b7:	85 c0                	test   %eax,%eax
  8019b9:	78 0e                	js     8019c9 <read+0xd6>
			return m;
		if (m == 0)
  8019bb:	85 c0                	test   %eax,%eax
  8019bd:	74 08                	je     8019c7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8019bf:	01 c3                	add    %eax,%ebx
  8019c1:	89 da                	mov    %ebx,%edx
  8019c3:	39 f3                	cmp    %esi,%ebx
  8019c5:	72 c5                	jb     80198c <read+0x99>
  8019c7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8019c9:	83 c4 2c             	add    $0x2c,%esp
  8019cc:	5b                   	pop    %ebx
  8019cd:	5e                   	pop    %esi
  8019ce:	5f                   	pop    %edi
  8019cf:	5d                   	pop    %ebp
  8019d0:	c3                   	ret    

008019d1 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8019d1:	55                   	push   %ebp
  8019d2:	89 e5                	mov    %esp,%ebp
  8019d4:	57                   	push   %edi
  8019d5:	56                   	push   %esi
  8019d6:	53                   	push   %ebx
  8019d7:	83 ec 1c             	sub    $0x1c,%esp
  8019da:	8b 7d 08             	mov    0x8(%ebp),%edi
  8019dd:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  8019e0:	ba 00 00 00 00       	mov    $0x0,%edx
  8019e5:	bb 00 00 00 00       	mov    $0x0,%ebx
  8019ea:	b8 00 00 00 00       	mov    $0x0,%eax
  8019ef:	85 f6                	test   %esi,%esi
  8019f1:	74 29                	je     801a1c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  8019f3:	89 f0                	mov    %esi,%eax
  8019f5:	29 d0                	sub    %edx,%eax
  8019f7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8019fb:	03 55 0c             	add    0xc(%ebp),%edx
  8019fe:	89 54 24 04          	mov    %edx,0x4(%esp)
  801a02:	89 3c 24             	mov    %edi,(%esp)
  801a05:	e8 e9 fe ff ff       	call   8018f3 <read>
		if (m < 0)
  801a0a:	85 c0                	test   %eax,%eax
  801a0c:	78 0e                	js     801a1c <readn+0x4b>
			return m;
		if (m == 0)
  801a0e:	85 c0                	test   %eax,%eax
  801a10:	74 08                	je     801a1a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801a12:	01 c3                	add    %eax,%ebx
  801a14:	89 da                	mov    %ebx,%edx
  801a16:	39 f3                	cmp    %esi,%ebx
  801a18:	72 d9                	jb     8019f3 <readn+0x22>
  801a1a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801a1c:	83 c4 1c             	add    $0x1c,%esp
  801a1f:	5b                   	pop    %ebx
  801a20:	5e                   	pop    %esi
  801a21:	5f                   	pop    %edi
  801a22:	5d                   	pop    %ebp
  801a23:	c3                   	ret    

00801a24 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801a24:	55                   	push   %ebp
  801a25:	89 e5                	mov    %esp,%ebp
  801a27:	83 ec 28             	sub    $0x28,%esp
  801a2a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a2d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a30:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801a33:	89 34 24             	mov    %esi,(%esp)
  801a36:	e8 b5 fb ff ff       	call   8015f0 <fd2num>
  801a3b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801a3e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801a42:	89 04 24             	mov    %eax,(%esp)
  801a45:	e8 43 fc ff ff       	call   80168d <fd_lookup>
  801a4a:	89 c3                	mov    %eax,%ebx
  801a4c:	85 c0                	test   %eax,%eax
  801a4e:	78 05                	js     801a55 <fd_close+0x31>
  801a50:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801a53:	74 0e                	je     801a63 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801a55:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801a59:	b8 00 00 00 00       	mov    $0x0,%eax
  801a5e:	0f 44 d8             	cmove  %eax,%ebx
  801a61:	eb 3d                	jmp    801aa0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801a63:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a66:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a6a:	8b 06                	mov    (%esi),%eax
  801a6c:	89 04 24             	mov    %eax,(%esp)
  801a6f:	e8 8d fc ff ff       	call   801701 <dev_lookup>
  801a74:	89 c3                	mov    %eax,%ebx
  801a76:	85 c0                	test   %eax,%eax
  801a78:	78 16                	js     801a90 <fd_close+0x6c>
		if (dev->dev_close)
  801a7a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a7d:	8b 40 10             	mov    0x10(%eax),%eax
  801a80:	bb 00 00 00 00       	mov    $0x0,%ebx
  801a85:	85 c0                	test   %eax,%eax
  801a87:	74 07                	je     801a90 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801a89:	89 34 24             	mov    %esi,(%esp)
  801a8c:	ff d0                	call   *%eax
  801a8e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801a90:	89 74 24 04          	mov    %esi,0x4(%esp)
  801a94:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a9b:	e8 9a f4 ff ff       	call   800f3a <sys_page_unmap>
	return r;
}
  801aa0:	89 d8                	mov    %ebx,%eax
  801aa2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801aa5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801aa8:	89 ec                	mov    %ebp,%esp
  801aaa:	5d                   	pop    %ebp
  801aab:	c3                   	ret    

00801aac <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801aac:	55                   	push   %ebp
  801aad:	89 e5                	mov    %esp,%ebp
  801aaf:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801ab2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ab5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ab9:	8b 45 08             	mov    0x8(%ebp),%eax
  801abc:	89 04 24             	mov    %eax,(%esp)
  801abf:	e8 c9 fb ff ff       	call   80168d <fd_lookup>
  801ac4:	85 c0                	test   %eax,%eax
  801ac6:	78 13                	js     801adb <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801ac8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801acf:	00 
  801ad0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ad3:	89 04 24             	mov    %eax,(%esp)
  801ad6:	e8 49 ff ff ff       	call   801a24 <fd_close>
}
  801adb:	c9                   	leave  
  801adc:	c3                   	ret    

00801add <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801add:	55                   	push   %ebp
  801ade:	89 e5                	mov    %esp,%ebp
  801ae0:	83 ec 18             	sub    $0x18,%esp
  801ae3:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801ae6:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801ae9:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801af0:	00 
  801af1:	8b 45 08             	mov    0x8(%ebp),%eax
  801af4:	89 04 24             	mov    %eax,(%esp)
  801af7:	e8 80 03 00 00       	call   801e7c <open>
  801afc:	89 c3                	mov    %eax,%ebx
  801afe:	85 c0                	test   %eax,%eax
  801b00:	78 1b                	js     801b1d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801b02:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b05:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b09:	89 1c 24             	mov    %ebx,(%esp)
  801b0c:	e8 5e fc ff ff       	call   80176f <fstat>
  801b11:	89 c6                	mov    %eax,%esi
	close(fd);
  801b13:	89 1c 24             	mov    %ebx,(%esp)
  801b16:	e8 91 ff ff ff       	call   801aac <close>
  801b1b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801b1d:	89 d8                	mov    %ebx,%eax
  801b1f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b22:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b25:	89 ec                	mov    %ebp,%esp
  801b27:	5d                   	pop    %ebp
  801b28:	c3                   	ret    

00801b29 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801b29:	55                   	push   %ebp
  801b2a:	89 e5                	mov    %esp,%ebp
  801b2c:	53                   	push   %ebx
  801b2d:	83 ec 14             	sub    $0x14,%esp
  801b30:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801b35:	89 1c 24             	mov    %ebx,(%esp)
  801b38:	e8 6f ff ff ff       	call   801aac <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801b3d:	83 c3 01             	add    $0x1,%ebx
  801b40:	83 fb 20             	cmp    $0x20,%ebx
  801b43:	75 f0                	jne    801b35 <close_all+0xc>
		close(i);
}
  801b45:	83 c4 14             	add    $0x14,%esp
  801b48:	5b                   	pop    %ebx
  801b49:	5d                   	pop    %ebp
  801b4a:	c3                   	ret    

00801b4b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801b4b:	55                   	push   %ebp
  801b4c:	89 e5                	mov    %esp,%ebp
  801b4e:	83 ec 58             	sub    $0x58,%esp
  801b51:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801b54:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801b57:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801b5a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801b5d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801b60:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b64:	8b 45 08             	mov    0x8(%ebp),%eax
  801b67:	89 04 24             	mov    %eax,(%esp)
  801b6a:	e8 1e fb ff ff       	call   80168d <fd_lookup>
  801b6f:	89 c3                	mov    %eax,%ebx
  801b71:	85 c0                	test   %eax,%eax
  801b73:	0f 88 e0 00 00 00    	js     801c59 <dup+0x10e>
		return r;
	close(newfdnum);
  801b79:	89 3c 24             	mov    %edi,(%esp)
  801b7c:	e8 2b ff ff ff       	call   801aac <close>

	newfd = INDEX2FD(newfdnum);
  801b81:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801b87:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801b8a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b8d:	89 04 24             	mov    %eax,(%esp)
  801b90:	e8 6b fa ff ff       	call   801600 <fd2data>
  801b95:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801b97:	89 34 24             	mov    %esi,(%esp)
  801b9a:	e8 61 fa ff ff       	call   801600 <fd2data>
  801b9f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801ba2:	89 da                	mov    %ebx,%edx
  801ba4:	89 d8                	mov    %ebx,%eax
  801ba6:	c1 e8 16             	shr    $0x16,%eax
  801ba9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801bb0:	a8 01                	test   $0x1,%al
  801bb2:	74 43                	je     801bf7 <dup+0xac>
  801bb4:	c1 ea 0c             	shr    $0xc,%edx
  801bb7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801bbe:	a8 01                	test   $0x1,%al
  801bc0:	74 35                	je     801bf7 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801bc2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801bc9:	25 07 0e 00 00       	and    $0xe07,%eax
  801bce:	89 44 24 10          	mov    %eax,0x10(%esp)
  801bd2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801bd5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801bd9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801be0:	00 
  801be1:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801be5:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801bec:	e8 a7 f3 ff ff       	call   800f98 <sys_page_map>
  801bf1:	89 c3                	mov    %eax,%ebx
  801bf3:	85 c0                	test   %eax,%eax
  801bf5:	78 3f                	js     801c36 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801bf7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801bfa:	89 c2                	mov    %eax,%edx
  801bfc:	c1 ea 0c             	shr    $0xc,%edx
  801bff:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801c06:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801c0c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801c10:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801c14:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801c1b:	00 
  801c1c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c20:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c27:	e8 6c f3 ff ff       	call   800f98 <sys_page_map>
  801c2c:	89 c3                	mov    %eax,%ebx
  801c2e:	85 c0                	test   %eax,%eax
  801c30:	78 04                	js     801c36 <dup+0xeb>
  801c32:	89 fb                	mov    %edi,%ebx
  801c34:	eb 23                	jmp    801c59 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801c36:	89 74 24 04          	mov    %esi,0x4(%esp)
  801c3a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c41:	e8 f4 f2 ff ff       	call   800f3a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801c46:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801c49:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c4d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c54:	e8 e1 f2 ff ff       	call   800f3a <sys_page_unmap>
	return r;
}
  801c59:	89 d8                	mov    %ebx,%eax
  801c5b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801c5e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801c61:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801c64:	89 ec                	mov    %ebp,%esp
  801c66:	5d                   	pop    %ebp
  801c67:	c3                   	ret    

00801c68 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801c68:	55                   	push   %ebp
  801c69:	89 e5                	mov    %esp,%ebp
  801c6b:	53                   	push   %ebx
  801c6c:	83 ec 14             	sub    $0x14,%esp
  801c6f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801c71:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801c77:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801c7e:	00 
  801c7f:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801c86:	00 
  801c87:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c8b:	89 14 24             	mov    %edx,(%esp)
  801c8e:	e8 8d f8 ff ff       	call   801520 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801c93:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801c9a:	00 
  801c9b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801c9f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ca6:	e8 e7 f8 ff ff       	call   801592 <ipc_recv>
}
  801cab:	83 c4 14             	add    $0x14,%esp
  801cae:	5b                   	pop    %ebx
  801caf:	5d                   	pop    %ebp
  801cb0:	c3                   	ret    

00801cb1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801cb1:	55                   	push   %ebp
  801cb2:	89 e5                	mov    %esp,%ebp
  801cb4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801cb7:	8b 45 08             	mov    0x8(%ebp),%eax
  801cba:	8b 40 0c             	mov    0xc(%eax),%eax
  801cbd:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801cc2:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cc5:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801cca:	ba 00 00 00 00       	mov    $0x0,%edx
  801ccf:	b8 02 00 00 00       	mov    $0x2,%eax
  801cd4:	e8 8f ff ff ff       	call   801c68 <fsipc>
}
  801cd9:	c9                   	leave  
  801cda:	c3                   	ret    

00801cdb <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801cdb:	55                   	push   %ebp
  801cdc:	89 e5                	mov    %esp,%ebp
  801cde:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801ce1:	8b 45 08             	mov    0x8(%ebp),%eax
  801ce4:	8b 40 0c             	mov    0xc(%eax),%eax
  801ce7:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801cec:	ba 00 00 00 00       	mov    $0x0,%edx
  801cf1:	b8 06 00 00 00       	mov    $0x6,%eax
  801cf6:	e8 6d ff ff ff       	call   801c68 <fsipc>
}
  801cfb:	c9                   	leave  
  801cfc:	c3                   	ret    

00801cfd <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801cfd:	55                   	push   %ebp
  801cfe:	89 e5                	mov    %esp,%ebp
  801d00:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801d03:	ba 00 00 00 00       	mov    $0x0,%edx
  801d08:	b8 08 00 00 00       	mov    $0x8,%eax
  801d0d:	e8 56 ff ff ff       	call   801c68 <fsipc>
}
  801d12:	c9                   	leave  
  801d13:	c3                   	ret    

00801d14 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801d14:	55                   	push   %ebp
  801d15:	89 e5                	mov    %esp,%ebp
  801d17:	53                   	push   %ebx
  801d18:	83 ec 14             	sub    $0x14,%esp
  801d1b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801d1e:	8b 45 08             	mov    0x8(%ebp),%eax
  801d21:	8b 40 0c             	mov    0xc(%eax),%eax
  801d24:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801d29:	ba 00 00 00 00       	mov    $0x0,%edx
  801d2e:	b8 05 00 00 00       	mov    $0x5,%eax
  801d33:	e8 30 ff ff ff       	call   801c68 <fsipc>
  801d38:	85 c0                	test   %eax,%eax
  801d3a:	78 2b                	js     801d67 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801d3c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801d43:	00 
  801d44:	89 1c 24             	mov    %ebx,(%esp)
  801d47:	e8 4e eb ff ff       	call   80089a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801d4c:	a1 80 40 80 00       	mov    0x804080,%eax
  801d51:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801d57:	a1 84 40 80 00       	mov    0x804084,%eax
  801d5c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801d62:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801d67:	83 c4 14             	add    $0x14,%esp
  801d6a:	5b                   	pop    %ebx
  801d6b:	5d                   	pop    %ebp
  801d6c:	c3                   	ret    

00801d6d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801d6d:	55                   	push   %ebp
  801d6e:	89 e5                	mov    %esp,%ebp
  801d70:	53                   	push   %ebx
  801d71:	83 ec 14             	sub    $0x14,%esp
  801d74:	8b 45 08             	mov    0x8(%ebp),%eax
  801d77:	8b 55 0c             	mov    0xc(%ebp),%edx
  801d7a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801d7d:	85 c0                	test   %eax,%eax
  801d7f:	74 44                	je     801dc5 <devfile_write+0x58>
  801d81:	85 d2                	test   %edx,%edx
  801d83:	74 40                	je     801dc5 <devfile_write+0x58>
  801d85:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801d8b:	77 38                	ja     801dc5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801d8d:	8b 40 0c             	mov    0xc(%eax),%eax
  801d90:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801d95:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801d9b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801d9f:	89 54 24 04          	mov    %edx,0x4(%esp)
  801da3:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801daa:	e8 a6 ec ff ff       	call   800a55 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801daf:	ba 00 00 00 00       	mov    $0x0,%edx
  801db4:	b8 04 00 00 00       	mov    $0x4,%eax
  801db9:	e8 aa fe ff ff       	call   801c68 <fsipc>
        return r;
    return n;
  801dbe:	85 c0                	test   %eax,%eax
  801dc0:	0f 49 c3             	cmovns %ebx,%eax
  801dc3:	eb 05                	jmp    801dca <devfile_write+0x5d>
  801dc5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801dca:	83 c4 14             	add    $0x14,%esp
  801dcd:	5b                   	pop    %ebx
  801dce:	5d                   	pop    %ebp
  801dcf:	c3                   	ret    

00801dd0 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801dd0:	55                   	push   %ebp
  801dd1:	89 e5                	mov    %esp,%ebp
  801dd3:	83 ec 18             	sub    $0x18,%esp
  801dd6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801dd9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801ddc:	8b 45 08             	mov    0x8(%ebp),%eax
  801ddf:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801de2:	85 c0                	test   %eax,%eax
  801de4:	74 04                	je     801dea <devfile_read+0x1a>
  801de6:	85 f6                	test   %esi,%esi
  801de8:	75 07                	jne    801df1 <devfile_read+0x21>
  801dea:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801def:	eb 39                	jmp    801e2a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801df1:	8b 40 0c             	mov    0xc(%eax),%eax
  801df4:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801df9:	8b 45 10             	mov    0x10(%ebp),%eax
  801dfc:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801e01:	ba 00 00 00 00       	mov    $0x0,%edx
  801e06:	b8 03 00 00 00       	mov    $0x3,%eax
  801e0b:	e8 58 fe ff ff       	call   801c68 <fsipc>
  801e10:	89 c3                	mov    %eax,%ebx
  801e12:	85 c0                	test   %eax,%eax
  801e14:	78 14                	js     801e2a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801e16:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e1a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801e21:	00 
  801e22:	89 34 24             	mov    %esi,(%esp)
  801e25:	e8 2b ec ff ff       	call   800a55 <memmove>
  return r;
}
  801e2a:	89 d8                	mov    %ebx,%eax
  801e2c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801e2f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801e32:	89 ec                	mov    %ebp,%esp
  801e34:	5d                   	pop    %ebp
  801e35:	c3                   	ret    

00801e36 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801e36:	55                   	push   %ebp
  801e37:	89 e5                	mov    %esp,%ebp
  801e39:	53                   	push   %ebx
  801e3a:	83 ec 14             	sub    $0x14,%esp
  801e3d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801e40:	89 1c 24             	mov    %ebx,(%esp)
  801e43:	e8 08 ea ff ff       	call   800850 <strlen>
  801e48:	89 c2                	mov    %eax,%edx
  801e4a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801e4f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801e55:	7f 1f                	jg     801e76 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801e57:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e5b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801e62:	e8 33 ea ff ff       	call   80089a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801e67:	ba 00 00 00 00       	mov    $0x0,%edx
  801e6c:	b8 07 00 00 00       	mov    $0x7,%eax
  801e71:	e8 f2 fd ff ff       	call   801c68 <fsipc>
}
  801e76:	83 c4 14             	add    $0x14,%esp
  801e79:	5b                   	pop    %ebx
  801e7a:	5d                   	pop    %ebp
  801e7b:	c3                   	ret    

00801e7c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801e7c:	55                   	push   %ebp
  801e7d:	89 e5                	mov    %esp,%ebp
  801e7f:	83 ec 28             	sub    $0x28,%esp
  801e82:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801e85:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801e88:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801e8b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801e90:	85 f6                	test   %esi,%esi
  801e92:	74 65                	je     801ef9 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801e94:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801e9b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801e9e:	89 04 24             	mov    %eax,(%esp)
  801ea1:	e8 75 f7 ff ff       	call   80161b <fd_alloc>
  801ea6:	89 c3                	mov    %eax,%ebx
  801ea8:	85 c0                	test   %eax,%eax
  801eaa:	78 4d                	js     801ef9 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801eac:	89 74 24 04          	mov    %esi,0x4(%esp)
  801eb0:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801eb7:	e8 de e9 ff ff       	call   80089a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801ebc:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ebf:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801ec4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801ec7:	b8 01 00 00 00       	mov    $0x1,%eax
  801ecc:	e8 97 fd ff ff       	call   801c68 <fsipc>
  801ed1:	89 c3                	mov    %eax,%ebx
  801ed3:	85 c0                	test   %eax,%eax
  801ed5:	79 15                	jns    801eec <open+0x70>
    fd_close(f, 0);
  801ed7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801ede:	00 
  801edf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ee2:	89 04 24             	mov    %eax,(%esp)
  801ee5:	e8 3a fb ff ff       	call   801a24 <fd_close>
    return r;
  801eea:	eb 0d                	jmp    801ef9 <open+0x7d>
  }
  return fd2num(f);
  801eec:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801eef:	89 04 24             	mov    %eax,(%esp)
  801ef2:	e8 f9 f6 ff ff       	call   8015f0 <fd2num>
  801ef7:	89 c3                	mov    %eax,%ebx
}
  801ef9:	89 d8                	mov    %ebx,%eax
  801efb:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801efe:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801f01:	89 ec                	mov    %ebp,%esp
  801f03:	5d                   	pop    %ebp
  801f04:	c3                   	ret    
	...

00801f10 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801f10:	55                   	push   %ebp
  801f11:	89 e5                	mov    %esp,%ebp
  801f13:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801f16:	c7 44 24 04 38 33 80 	movl   $0x803338,0x4(%esp)
  801f1d:	00 
  801f1e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f21:	89 04 24             	mov    %eax,(%esp)
  801f24:	e8 71 e9 ff ff       	call   80089a <strcpy>
	return 0;
}
  801f29:	b8 00 00 00 00       	mov    $0x0,%eax
  801f2e:	c9                   	leave  
  801f2f:	c3                   	ret    

00801f30 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801f30:	55                   	push   %ebp
  801f31:	89 e5                	mov    %esp,%ebp
  801f33:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801f36:	8b 45 08             	mov    0x8(%ebp),%eax
  801f39:	8b 40 0c             	mov    0xc(%eax),%eax
  801f3c:	89 04 24             	mov    %eax,(%esp)
  801f3f:	e8 9d 02 00 00       	call   8021e1 <nsipc_close>
}
  801f44:	c9                   	leave  
  801f45:	c3                   	ret    

00801f46 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801f46:	55                   	push   %ebp
  801f47:	89 e5                	mov    %esp,%ebp
  801f49:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801f4c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801f53:	00 
  801f54:	8b 45 10             	mov    0x10(%ebp),%eax
  801f57:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f5b:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f5e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f62:	8b 45 08             	mov    0x8(%ebp),%eax
  801f65:	8b 40 0c             	mov    0xc(%eax),%eax
  801f68:	89 04 24             	mov    %eax,(%esp)
  801f6b:	e8 ad 02 00 00       	call   80221d <nsipc_send>
}
  801f70:	c9                   	leave  
  801f71:	c3                   	ret    

00801f72 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801f72:	55                   	push   %ebp
  801f73:	89 e5                	mov    %esp,%ebp
  801f75:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801f78:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801f7f:	00 
  801f80:	8b 45 10             	mov    0x10(%ebp),%eax
  801f83:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f87:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f8a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f8e:	8b 45 08             	mov    0x8(%ebp),%eax
  801f91:	8b 40 0c             	mov    0xc(%eax),%eax
  801f94:	89 04 24             	mov    %eax,(%esp)
  801f97:	e8 f4 02 00 00       	call   802290 <nsipc_recv>
}
  801f9c:	c9                   	leave  
  801f9d:	c3                   	ret    

00801f9e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801f9e:	55                   	push   %ebp
  801f9f:	89 e5                	mov    %esp,%ebp
  801fa1:	56                   	push   %esi
  801fa2:	53                   	push   %ebx
  801fa3:	83 ec 20             	sub    $0x20,%esp
  801fa6:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801fa8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801fab:	89 04 24             	mov    %eax,(%esp)
  801fae:	e8 68 f6 ff ff       	call   80161b <fd_alloc>
  801fb3:	89 c3                	mov    %eax,%ebx
  801fb5:	85 c0                	test   %eax,%eax
  801fb7:	78 21                	js     801fda <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801fb9:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801fc0:	00 
  801fc1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801fc4:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fc8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801fcf:	e8 22 f0 ff ff       	call   800ff6 <sys_page_alloc>
  801fd4:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801fd6:	85 c0                	test   %eax,%eax
  801fd8:	79 0a                	jns    801fe4 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801fda:	89 34 24             	mov    %esi,(%esp)
  801fdd:	e8 ff 01 00 00       	call   8021e1 <nsipc_close>
		return r;
  801fe2:	eb 28                	jmp    80200c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801fe4:	8b 15 20 70 80 00    	mov    0x807020,%edx
  801fea:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801fed:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801fef:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ff2:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801ff9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ffc:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801fff:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802002:	89 04 24             	mov    %eax,(%esp)
  802005:	e8 e6 f5 ff ff       	call   8015f0 <fd2num>
  80200a:	89 c3                	mov    %eax,%ebx
}
  80200c:	89 d8                	mov    %ebx,%eax
  80200e:	83 c4 20             	add    $0x20,%esp
  802011:	5b                   	pop    %ebx
  802012:	5e                   	pop    %esi
  802013:	5d                   	pop    %ebp
  802014:	c3                   	ret    

00802015 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  802015:	55                   	push   %ebp
  802016:	89 e5                	mov    %esp,%ebp
  802018:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  80201b:	8b 45 10             	mov    0x10(%ebp),%eax
  80201e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802022:	8b 45 0c             	mov    0xc(%ebp),%eax
  802025:	89 44 24 04          	mov    %eax,0x4(%esp)
  802029:	8b 45 08             	mov    0x8(%ebp),%eax
  80202c:	89 04 24             	mov    %eax,(%esp)
  80202f:	e8 61 01 00 00       	call   802195 <nsipc_socket>
  802034:	85 c0                	test   %eax,%eax
  802036:	78 05                	js     80203d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  802038:	e8 61 ff ff ff       	call   801f9e <alloc_sockfd>
}
  80203d:	c9                   	leave  
  80203e:	66 90                	xchg   %ax,%ax
  802040:	c3                   	ret    

00802041 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  802041:	55                   	push   %ebp
  802042:	89 e5                	mov    %esp,%ebp
  802044:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  802047:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80204a:	89 54 24 04          	mov    %edx,0x4(%esp)
  80204e:	89 04 24             	mov    %eax,(%esp)
  802051:	e8 37 f6 ff ff       	call   80168d <fd_lookup>
  802056:	85 c0                	test   %eax,%eax
  802058:	78 15                	js     80206f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  80205a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80205d:	8b 0a                	mov    (%edx),%ecx
  80205f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802064:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  80206a:	75 03                	jne    80206f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  80206c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  80206f:	c9                   	leave  
  802070:	c3                   	ret    

00802071 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802071:	55                   	push   %ebp
  802072:	89 e5                	mov    %esp,%ebp
  802074:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802077:	8b 45 08             	mov    0x8(%ebp),%eax
  80207a:	e8 c2 ff ff ff       	call   802041 <fd2sockid>
  80207f:	85 c0                	test   %eax,%eax
  802081:	78 0f                	js     802092 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802083:	8b 55 0c             	mov    0xc(%ebp),%edx
  802086:	89 54 24 04          	mov    %edx,0x4(%esp)
  80208a:	89 04 24             	mov    %eax,(%esp)
  80208d:	e8 2d 01 00 00       	call   8021bf <nsipc_listen>
}
  802092:	c9                   	leave  
  802093:	c3                   	ret    

00802094 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802094:	55                   	push   %ebp
  802095:	89 e5                	mov    %esp,%ebp
  802097:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80209a:	8b 45 08             	mov    0x8(%ebp),%eax
  80209d:	e8 9f ff ff ff       	call   802041 <fd2sockid>
  8020a2:	85 c0                	test   %eax,%eax
  8020a4:	78 16                	js     8020bc <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  8020a6:	8b 55 10             	mov    0x10(%ebp),%edx
  8020a9:	89 54 24 08          	mov    %edx,0x8(%esp)
  8020ad:	8b 55 0c             	mov    0xc(%ebp),%edx
  8020b0:	89 54 24 04          	mov    %edx,0x4(%esp)
  8020b4:	89 04 24             	mov    %eax,(%esp)
  8020b7:	e8 54 02 00 00       	call   802310 <nsipc_connect>
}
  8020bc:	c9                   	leave  
  8020bd:	c3                   	ret    

008020be <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  8020be:	55                   	push   %ebp
  8020bf:	89 e5                	mov    %esp,%ebp
  8020c1:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8020c4:	8b 45 08             	mov    0x8(%ebp),%eax
  8020c7:	e8 75 ff ff ff       	call   802041 <fd2sockid>
  8020cc:	85 c0                	test   %eax,%eax
  8020ce:	78 0f                	js     8020df <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  8020d0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8020d3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8020d7:	89 04 24             	mov    %eax,(%esp)
  8020da:	e8 1c 01 00 00       	call   8021fb <nsipc_shutdown>
}
  8020df:	c9                   	leave  
  8020e0:	c3                   	ret    

008020e1 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8020e1:	55                   	push   %ebp
  8020e2:	89 e5                	mov    %esp,%ebp
  8020e4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8020e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8020ea:	e8 52 ff ff ff       	call   802041 <fd2sockid>
  8020ef:	85 c0                	test   %eax,%eax
  8020f1:	78 16                	js     802109 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  8020f3:	8b 55 10             	mov    0x10(%ebp),%edx
  8020f6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8020fa:	8b 55 0c             	mov    0xc(%ebp),%edx
  8020fd:	89 54 24 04          	mov    %edx,0x4(%esp)
  802101:	89 04 24             	mov    %eax,(%esp)
  802104:	e8 46 02 00 00       	call   80234f <nsipc_bind>
}
  802109:	c9                   	leave  
  80210a:	c3                   	ret    

0080210b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80210b:	55                   	push   %ebp
  80210c:	89 e5                	mov    %esp,%ebp
  80210e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802111:	8b 45 08             	mov    0x8(%ebp),%eax
  802114:	e8 28 ff ff ff       	call   802041 <fd2sockid>
  802119:	85 c0                	test   %eax,%eax
  80211b:	78 1f                	js     80213c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80211d:	8b 55 10             	mov    0x10(%ebp),%edx
  802120:	89 54 24 08          	mov    %edx,0x8(%esp)
  802124:	8b 55 0c             	mov    0xc(%ebp),%edx
  802127:	89 54 24 04          	mov    %edx,0x4(%esp)
  80212b:	89 04 24             	mov    %eax,(%esp)
  80212e:	e8 5b 02 00 00       	call   80238e <nsipc_accept>
  802133:	85 c0                	test   %eax,%eax
  802135:	78 05                	js     80213c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802137:	e8 62 fe ff ff       	call   801f9e <alloc_sockfd>
}
  80213c:	c9                   	leave  
  80213d:	8d 76 00             	lea    0x0(%esi),%esi
  802140:	c3                   	ret    
	...

00802150 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802150:	55                   	push   %ebp
  802151:	89 e5                	mov    %esp,%ebp
  802153:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802156:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80215c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802163:	00 
  802164:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80216b:	00 
  80216c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802170:	89 14 24             	mov    %edx,(%esp)
  802173:	e8 a8 f3 ff ff       	call   801520 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802178:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80217f:	00 
  802180:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802187:	00 
  802188:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80218b:	89 04 24             	mov    %eax,(%esp)
  80218e:	e8 ff f3 ff ff       	call   801592 <ipc_recv>
    return r;
}
  802193:	c9                   	leave  
  802194:	c3                   	ret    

00802195 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802195:	55                   	push   %ebp
  802196:	89 e5                	mov    %esp,%ebp
  802198:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80219b:	8b 45 08             	mov    0x8(%ebp),%eax
  80219e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  8021a3:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021a6:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  8021ab:	8b 45 10             	mov    0x10(%ebp),%eax
  8021ae:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  8021b3:	b8 09 00 00 00       	mov    $0x9,%eax
  8021b8:	e8 93 ff ff ff       	call   802150 <nsipc>
}
  8021bd:	c9                   	leave  
  8021be:	c3                   	ret    

008021bf <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  8021bf:	55                   	push   %ebp
  8021c0:	89 e5                	mov    %esp,%ebp
  8021c2:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  8021c5:	8b 45 08             	mov    0x8(%ebp),%eax
  8021c8:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  8021cd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021d0:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  8021d5:	b8 06 00 00 00       	mov    $0x6,%eax
  8021da:	e8 71 ff ff ff       	call   802150 <nsipc>
}
  8021df:	c9                   	leave  
  8021e0:	c3                   	ret    

008021e1 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  8021e1:	55                   	push   %ebp
  8021e2:	89 e5                	mov    %esp,%ebp
  8021e4:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  8021e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8021ea:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  8021ef:	b8 04 00 00 00       	mov    $0x4,%eax
  8021f4:	e8 57 ff ff ff       	call   802150 <nsipc>
}
  8021f9:	c9                   	leave  
  8021fa:	c3                   	ret    

008021fb <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  8021fb:	55                   	push   %ebp
  8021fc:	89 e5                	mov    %esp,%ebp
  8021fe:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802201:	8b 45 08             	mov    0x8(%ebp),%eax
  802204:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802209:	8b 45 0c             	mov    0xc(%ebp),%eax
  80220c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802211:	b8 03 00 00 00       	mov    $0x3,%eax
  802216:	e8 35 ff ff ff       	call   802150 <nsipc>
}
  80221b:	c9                   	leave  
  80221c:	c3                   	ret    

0080221d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80221d:	55                   	push   %ebp
  80221e:	89 e5                	mov    %esp,%ebp
  802220:	53                   	push   %ebx
  802221:	83 ec 14             	sub    $0x14,%esp
  802224:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802227:	8b 45 08             	mov    0x8(%ebp),%eax
  80222a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80222f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802235:	7e 24                	jle    80225b <nsipc_send+0x3e>
  802237:	c7 44 24 0c 44 33 80 	movl   $0x803344,0xc(%esp)
  80223e:	00 
  80223f:	c7 44 24 08 50 33 80 	movl   $0x803350,0x8(%esp)
  802246:	00 
  802247:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  80224e:	00 
  80224f:	c7 04 24 65 33 80 00 	movl   $0x803365,(%esp)
  802256:	e8 29 07 00 00       	call   802984 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80225b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80225f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802262:	89 44 24 04          	mov    %eax,0x4(%esp)
  802266:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80226d:	e8 e3 e7 ff ff       	call   800a55 <memmove>
	nsipcbuf.send.req_size = size;
  802272:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802278:	8b 45 14             	mov    0x14(%ebp),%eax
  80227b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802280:	b8 08 00 00 00       	mov    $0x8,%eax
  802285:	e8 c6 fe ff ff       	call   802150 <nsipc>
}
  80228a:	83 c4 14             	add    $0x14,%esp
  80228d:	5b                   	pop    %ebx
  80228e:	5d                   	pop    %ebp
  80228f:	c3                   	ret    

00802290 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802290:	55                   	push   %ebp
  802291:	89 e5                	mov    %esp,%ebp
  802293:	56                   	push   %esi
  802294:	53                   	push   %ebx
  802295:	83 ec 10             	sub    $0x10,%esp
  802298:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80229b:	8b 45 08             	mov    0x8(%ebp),%eax
  80229e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  8022a3:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  8022a9:	8b 45 14             	mov    0x14(%ebp),%eax
  8022ac:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  8022b1:	b8 07 00 00 00       	mov    $0x7,%eax
  8022b6:	e8 95 fe ff ff       	call   802150 <nsipc>
  8022bb:	89 c3                	mov    %eax,%ebx
  8022bd:	85 c0                	test   %eax,%eax
  8022bf:	78 46                	js     802307 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  8022c1:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  8022c6:	7f 04                	jg     8022cc <nsipc_recv+0x3c>
  8022c8:	39 c6                	cmp    %eax,%esi
  8022ca:	7d 24                	jge    8022f0 <nsipc_recv+0x60>
  8022cc:	c7 44 24 0c 71 33 80 	movl   $0x803371,0xc(%esp)
  8022d3:	00 
  8022d4:	c7 44 24 08 50 33 80 	movl   $0x803350,0x8(%esp)
  8022db:	00 
  8022dc:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  8022e3:	00 
  8022e4:	c7 04 24 65 33 80 00 	movl   $0x803365,(%esp)
  8022eb:	e8 94 06 00 00       	call   802984 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  8022f0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8022f4:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8022fb:	00 
  8022fc:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022ff:	89 04 24             	mov    %eax,(%esp)
  802302:	e8 4e e7 ff ff       	call   800a55 <memmove>
	}

	return r;
}
  802307:	89 d8                	mov    %ebx,%eax
  802309:	83 c4 10             	add    $0x10,%esp
  80230c:	5b                   	pop    %ebx
  80230d:	5e                   	pop    %esi
  80230e:	5d                   	pop    %ebp
  80230f:	c3                   	ret    

00802310 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802310:	55                   	push   %ebp
  802311:	89 e5                	mov    %esp,%ebp
  802313:	53                   	push   %ebx
  802314:	83 ec 14             	sub    $0x14,%esp
  802317:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80231a:	8b 45 08             	mov    0x8(%ebp),%eax
  80231d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802322:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802326:	8b 45 0c             	mov    0xc(%ebp),%eax
  802329:	89 44 24 04          	mov    %eax,0x4(%esp)
  80232d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802334:	e8 1c e7 ff ff       	call   800a55 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802339:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  80233f:	b8 05 00 00 00       	mov    $0x5,%eax
  802344:	e8 07 fe ff ff       	call   802150 <nsipc>
}
  802349:	83 c4 14             	add    $0x14,%esp
  80234c:	5b                   	pop    %ebx
  80234d:	5d                   	pop    %ebp
  80234e:	c3                   	ret    

0080234f <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  80234f:	55                   	push   %ebp
  802350:	89 e5                	mov    %esp,%ebp
  802352:	53                   	push   %ebx
  802353:	83 ec 14             	sub    $0x14,%esp
  802356:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802359:	8b 45 08             	mov    0x8(%ebp),%eax
  80235c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802361:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802365:	8b 45 0c             	mov    0xc(%ebp),%eax
  802368:	89 44 24 04          	mov    %eax,0x4(%esp)
  80236c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802373:	e8 dd e6 ff ff       	call   800a55 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802378:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80237e:	b8 02 00 00 00       	mov    $0x2,%eax
  802383:	e8 c8 fd ff ff       	call   802150 <nsipc>
}
  802388:	83 c4 14             	add    $0x14,%esp
  80238b:	5b                   	pop    %ebx
  80238c:	5d                   	pop    %ebp
  80238d:	c3                   	ret    

0080238e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80238e:	55                   	push   %ebp
  80238f:	89 e5                	mov    %esp,%ebp
  802391:	83 ec 18             	sub    $0x18,%esp
  802394:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802397:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80239a:	8b 45 08             	mov    0x8(%ebp),%eax
  80239d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  8023a2:	b8 01 00 00 00       	mov    $0x1,%eax
  8023a7:	e8 a4 fd ff ff       	call   802150 <nsipc>
  8023ac:	89 c3                	mov    %eax,%ebx
  8023ae:	85 c0                	test   %eax,%eax
  8023b0:	78 25                	js     8023d7 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  8023b2:	be 10 60 80 00       	mov    $0x806010,%esi
  8023b7:	8b 06                	mov    (%esi),%eax
  8023b9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8023bd:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8023c4:	00 
  8023c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023c8:	89 04 24             	mov    %eax,(%esp)
  8023cb:	e8 85 e6 ff ff       	call   800a55 <memmove>
		*addrlen = ret->ret_addrlen;
  8023d0:	8b 16                	mov    (%esi),%edx
  8023d2:	8b 45 10             	mov    0x10(%ebp),%eax
  8023d5:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  8023d7:	89 d8                	mov    %ebx,%eax
  8023d9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8023dc:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8023df:	89 ec                	mov    %ebp,%esp
  8023e1:	5d                   	pop    %ebp
  8023e2:	c3                   	ret    
	...

008023f0 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8023f0:	55                   	push   %ebp
  8023f1:	89 e5                	mov    %esp,%ebp
  8023f3:	83 ec 18             	sub    $0x18,%esp
  8023f6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8023f9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8023fc:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8023ff:	8b 45 08             	mov    0x8(%ebp),%eax
  802402:	89 04 24             	mov    %eax,(%esp)
  802405:	e8 f6 f1 ff ff       	call   801600 <fd2data>
  80240a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80240c:	c7 44 24 04 86 33 80 	movl   $0x803386,0x4(%esp)
  802413:	00 
  802414:	89 34 24             	mov    %esi,(%esp)
  802417:	e8 7e e4 ff ff       	call   80089a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80241c:	8b 43 04             	mov    0x4(%ebx),%eax
  80241f:	2b 03                	sub    (%ebx),%eax
  802421:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802427:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80242e:	00 00 00 
	stat->st_dev = &devpipe;
  802431:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  802438:	70 80 00 
	return 0;
}
  80243b:	b8 00 00 00 00       	mov    $0x0,%eax
  802440:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802443:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802446:	89 ec                	mov    %ebp,%esp
  802448:	5d                   	pop    %ebp
  802449:	c3                   	ret    

0080244a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80244a:	55                   	push   %ebp
  80244b:	89 e5                	mov    %esp,%ebp
  80244d:	53                   	push   %ebx
  80244e:	83 ec 14             	sub    $0x14,%esp
  802451:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802454:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802458:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80245f:	e8 d6 ea ff ff       	call   800f3a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802464:	89 1c 24             	mov    %ebx,(%esp)
  802467:	e8 94 f1 ff ff       	call   801600 <fd2data>
  80246c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802470:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802477:	e8 be ea ff ff       	call   800f3a <sys_page_unmap>
}
  80247c:	83 c4 14             	add    $0x14,%esp
  80247f:	5b                   	pop    %ebx
  802480:	5d                   	pop    %ebp
  802481:	c3                   	ret    

00802482 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802482:	55                   	push   %ebp
  802483:	89 e5                	mov    %esp,%ebp
  802485:	57                   	push   %edi
  802486:	56                   	push   %esi
  802487:	53                   	push   %ebx
  802488:	83 ec 2c             	sub    $0x2c,%esp
  80248b:	89 c7                	mov    %eax,%edi
  80248d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802490:	a1 74 70 80 00       	mov    0x807074,%eax
  802495:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802498:	89 3c 24             	mov    %edi,(%esp)
  80249b:	e8 e0 05 00 00       	call   802a80 <pageref>
  8024a0:	89 c6                	mov    %eax,%esi
  8024a2:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8024a5:	89 04 24             	mov    %eax,(%esp)
  8024a8:	e8 d3 05 00 00       	call   802a80 <pageref>
  8024ad:	39 c6                	cmp    %eax,%esi
  8024af:	0f 94 c0             	sete   %al
  8024b2:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  8024b5:	8b 15 74 70 80 00    	mov    0x807074,%edx
  8024bb:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  8024be:	39 cb                	cmp    %ecx,%ebx
  8024c0:	75 08                	jne    8024ca <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  8024c2:	83 c4 2c             	add    $0x2c,%esp
  8024c5:	5b                   	pop    %ebx
  8024c6:	5e                   	pop    %esi
  8024c7:	5f                   	pop    %edi
  8024c8:	5d                   	pop    %ebp
  8024c9:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  8024ca:	83 f8 01             	cmp    $0x1,%eax
  8024cd:	75 c1                	jne    802490 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  8024cf:	8b 52 58             	mov    0x58(%edx),%edx
  8024d2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024d6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8024da:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8024de:	c7 04 24 8d 33 80 00 	movl   $0x80338d,(%esp)
  8024e5:	e8 db dc ff ff       	call   8001c5 <cprintf>
  8024ea:	eb a4                	jmp    802490 <_pipeisclosed+0xe>

008024ec <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  8024ec:	55                   	push   %ebp
  8024ed:	89 e5                	mov    %esp,%ebp
  8024ef:	57                   	push   %edi
  8024f0:	56                   	push   %esi
  8024f1:	53                   	push   %ebx
  8024f2:	83 ec 1c             	sub    $0x1c,%esp
  8024f5:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  8024f8:	89 34 24             	mov    %esi,(%esp)
  8024fb:	e8 00 f1 ff ff       	call   801600 <fd2data>
  802500:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802502:	bf 00 00 00 00       	mov    $0x0,%edi
  802507:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80250b:	75 54                	jne    802561 <devpipe_write+0x75>
  80250d:	eb 60                	jmp    80256f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80250f:	89 da                	mov    %ebx,%edx
  802511:	89 f0                	mov    %esi,%eax
  802513:	e8 6a ff ff ff       	call   802482 <_pipeisclosed>
  802518:	85 c0                	test   %eax,%eax
  80251a:	74 07                	je     802523 <devpipe_write+0x37>
  80251c:	b8 00 00 00 00       	mov    $0x0,%eax
  802521:	eb 53                	jmp    802576 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802523:	90                   	nop
  802524:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802528:	e8 28 eb ff ff       	call   801055 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80252d:	8b 43 04             	mov    0x4(%ebx),%eax
  802530:	8b 13                	mov    (%ebx),%edx
  802532:	83 c2 20             	add    $0x20,%edx
  802535:	39 d0                	cmp    %edx,%eax
  802537:	73 d6                	jae    80250f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802539:	89 c2                	mov    %eax,%edx
  80253b:	c1 fa 1f             	sar    $0x1f,%edx
  80253e:	c1 ea 1b             	shr    $0x1b,%edx
  802541:	01 d0                	add    %edx,%eax
  802543:	83 e0 1f             	and    $0x1f,%eax
  802546:	29 d0                	sub    %edx,%eax
  802548:	89 c2                	mov    %eax,%edx
  80254a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80254d:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802551:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802555:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802559:	83 c7 01             	add    $0x1,%edi
  80255c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80255f:	76 13                	jbe    802574 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802561:	8b 43 04             	mov    0x4(%ebx),%eax
  802564:	8b 13                	mov    (%ebx),%edx
  802566:	83 c2 20             	add    $0x20,%edx
  802569:	39 d0                	cmp    %edx,%eax
  80256b:	73 a2                	jae    80250f <devpipe_write+0x23>
  80256d:	eb ca                	jmp    802539 <devpipe_write+0x4d>
  80256f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802574:	89 f8                	mov    %edi,%eax
}
  802576:	83 c4 1c             	add    $0x1c,%esp
  802579:	5b                   	pop    %ebx
  80257a:	5e                   	pop    %esi
  80257b:	5f                   	pop    %edi
  80257c:	5d                   	pop    %ebp
  80257d:	c3                   	ret    

0080257e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80257e:	55                   	push   %ebp
  80257f:	89 e5                	mov    %esp,%ebp
  802581:	83 ec 28             	sub    $0x28,%esp
  802584:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802587:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80258a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80258d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802590:	89 3c 24             	mov    %edi,(%esp)
  802593:	e8 68 f0 ff ff       	call   801600 <fd2data>
  802598:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80259a:	be 00 00 00 00       	mov    $0x0,%esi
  80259f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8025a3:	75 4c                	jne    8025f1 <devpipe_read+0x73>
  8025a5:	eb 5b                	jmp    802602 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  8025a7:	89 f0                	mov    %esi,%eax
  8025a9:	eb 5e                	jmp    802609 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  8025ab:	89 da                	mov    %ebx,%edx
  8025ad:	89 f8                	mov    %edi,%eax
  8025af:	90                   	nop
  8025b0:	e8 cd fe ff ff       	call   802482 <_pipeisclosed>
  8025b5:	85 c0                	test   %eax,%eax
  8025b7:	74 07                	je     8025c0 <devpipe_read+0x42>
  8025b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8025be:	eb 49                	jmp    802609 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  8025c0:	e8 90 ea ff ff       	call   801055 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  8025c5:	8b 03                	mov    (%ebx),%eax
  8025c7:	3b 43 04             	cmp    0x4(%ebx),%eax
  8025ca:	74 df                	je     8025ab <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  8025cc:	89 c2                	mov    %eax,%edx
  8025ce:	c1 fa 1f             	sar    $0x1f,%edx
  8025d1:	c1 ea 1b             	shr    $0x1b,%edx
  8025d4:	01 d0                	add    %edx,%eax
  8025d6:	83 e0 1f             	and    $0x1f,%eax
  8025d9:	29 d0                	sub    %edx,%eax
  8025db:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  8025e0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8025e3:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  8025e6:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8025e9:	83 c6 01             	add    $0x1,%esi
  8025ec:	39 75 10             	cmp    %esi,0x10(%ebp)
  8025ef:	76 16                	jbe    802607 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  8025f1:	8b 03                	mov    (%ebx),%eax
  8025f3:	3b 43 04             	cmp    0x4(%ebx),%eax
  8025f6:	75 d4                	jne    8025cc <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  8025f8:	85 f6                	test   %esi,%esi
  8025fa:	75 ab                	jne    8025a7 <devpipe_read+0x29>
  8025fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802600:	eb a9                	jmp    8025ab <devpipe_read+0x2d>
  802602:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802607:	89 f0                	mov    %esi,%eax
}
  802609:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80260c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80260f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802612:	89 ec                	mov    %ebp,%esp
  802614:	5d                   	pop    %ebp
  802615:	c3                   	ret    

00802616 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802616:	55                   	push   %ebp
  802617:	89 e5                	mov    %esp,%ebp
  802619:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80261c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80261f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802623:	8b 45 08             	mov    0x8(%ebp),%eax
  802626:	89 04 24             	mov    %eax,(%esp)
  802629:	e8 5f f0 ff ff       	call   80168d <fd_lookup>
  80262e:	85 c0                	test   %eax,%eax
  802630:	78 15                	js     802647 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802632:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802635:	89 04 24             	mov    %eax,(%esp)
  802638:	e8 c3 ef ff ff       	call   801600 <fd2data>
	return _pipeisclosed(fd, p);
  80263d:	89 c2                	mov    %eax,%edx
  80263f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802642:	e8 3b fe ff ff       	call   802482 <_pipeisclosed>
}
  802647:	c9                   	leave  
  802648:	c3                   	ret    

00802649 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802649:	55                   	push   %ebp
  80264a:	89 e5                	mov    %esp,%ebp
  80264c:	83 ec 48             	sub    $0x48,%esp
  80264f:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802652:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802655:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802658:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80265b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80265e:	89 04 24             	mov    %eax,(%esp)
  802661:	e8 b5 ef ff ff       	call   80161b <fd_alloc>
  802666:	89 c3                	mov    %eax,%ebx
  802668:	85 c0                	test   %eax,%eax
  80266a:	0f 88 42 01 00 00    	js     8027b2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802670:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802677:	00 
  802678:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80267b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80267f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802686:	e8 6b e9 ff ff       	call   800ff6 <sys_page_alloc>
  80268b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80268d:	85 c0                	test   %eax,%eax
  80268f:	0f 88 1d 01 00 00    	js     8027b2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802695:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802698:	89 04 24             	mov    %eax,(%esp)
  80269b:	e8 7b ef ff ff       	call   80161b <fd_alloc>
  8026a0:	89 c3                	mov    %eax,%ebx
  8026a2:	85 c0                	test   %eax,%eax
  8026a4:	0f 88 f5 00 00 00    	js     80279f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8026aa:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8026b1:	00 
  8026b2:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026b9:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026c0:	e8 31 e9 ff ff       	call   800ff6 <sys_page_alloc>
  8026c5:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8026c7:	85 c0                	test   %eax,%eax
  8026c9:	0f 88 d0 00 00 00    	js     80279f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  8026cf:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8026d2:	89 04 24             	mov    %eax,(%esp)
  8026d5:	e8 26 ef ff ff       	call   801600 <fd2data>
  8026da:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8026dc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8026e3:	00 
  8026e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026ef:	e8 02 e9 ff ff       	call   800ff6 <sys_page_alloc>
  8026f4:	89 c3                	mov    %eax,%ebx
  8026f6:	85 c0                	test   %eax,%eax
  8026f8:	0f 88 8e 00 00 00    	js     80278c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8026fe:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802701:	89 04 24             	mov    %eax,(%esp)
  802704:	e8 f7 ee ff ff       	call   801600 <fd2data>
  802709:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802710:	00 
  802711:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802715:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80271c:	00 
  80271d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802721:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802728:	e8 6b e8 ff ff       	call   800f98 <sys_page_map>
  80272d:	89 c3                	mov    %eax,%ebx
  80272f:	85 c0                	test   %eax,%eax
  802731:	78 49                	js     80277c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802733:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802738:	8b 08                	mov    (%eax),%ecx
  80273a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80273d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80273f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802742:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802749:	8b 10                	mov    (%eax),%edx
  80274b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80274e:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802750:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802753:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80275a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80275d:	89 04 24             	mov    %eax,(%esp)
  802760:	e8 8b ee ff ff       	call   8015f0 <fd2num>
  802765:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802767:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80276a:	89 04 24             	mov    %eax,(%esp)
  80276d:	e8 7e ee ff ff       	call   8015f0 <fd2num>
  802772:	89 47 04             	mov    %eax,0x4(%edi)
  802775:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80277a:	eb 36                	jmp    8027b2 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80277c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802780:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802787:	e8 ae e7 ff ff       	call   800f3a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  80278c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80278f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802793:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80279a:	e8 9b e7 ff ff       	call   800f3a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80279f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8027a2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027a6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8027ad:	e8 88 e7 ff ff       	call   800f3a <sys_page_unmap>
    err:
	return r;
}
  8027b2:	89 d8                	mov    %ebx,%eax
  8027b4:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8027b7:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8027ba:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8027bd:	89 ec                	mov    %ebp,%esp
  8027bf:	5d                   	pop    %ebp
  8027c0:	c3                   	ret    
	...

008027d0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8027d0:	55                   	push   %ebp
  8027d1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  8027d3:	b8 00 00 00 00       	mov    $0x0,%eax
  8027d8:	5d                   	pop    %ebp
  8027d9:	c3                   	ret    

008027da <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8027da:	55                   	push   %ebp
  8027db:	89 e5                	mov    %esp,%ebp
  8027dd:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  8027e0:	c7 44 24 04 a5 33 80 	movl   $0x8033a5,0x4(%esp)
  8027e7:	00 
  8027e8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027eb:	89 04 24             	mov    %eax,(%esp)
  8027ee:	e8 a7 e0 ff ff       	call   80089a <strcpy>
	return 0;
}
  8027f3:	b8 00 00 00 00       	mov    $0x0,%eax
  8027f8:	c9                   	leave  
  8027f9:	c3                   	ret    

008027fa <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  8027fa:	55                   	push   %ebp
  8027fb:	89 e5                	mov    %esp,%ebp
  8027fd:	57                   	push   %edi
  8027fe:	56                   	push   %esi
  8027ff:	53                   	push   %ebx
  802800:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802806:	b8 00 00 00 00       	mov    $0x0,%eax
  80280b:	be 00 00 00 00       	mov    $0x0,%esi
  802810:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802814:	74 41                	je     802857 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802816:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80281c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80281f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802821:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802827:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80282c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80282f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802833:	03 45 0c             	add    0xc(%ebp),%eax
  802836:	89 44 24 04          	mov    %eax,0x4(%esp)
  80283a:	89 3c 24             	mov    %edi,(%esp)
  80283d:	e8 13 e2 ff ff       	call   800a55 <memmove>
		sys_cputs(buf, m);
  802842:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802846:	89 3c 24             	mov    %edi,(%esp)
  802849:	e8 42 e4 ff ff       	call   800c90 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  80284e:	01 de                	add    %ebx,%esi
  802850:	89 f0                	mov    %esi,%eax
  802852:	3b 75 10             	cmp    0x10(%ebp),%esi
  802855:	72 c5                	jb     80281c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802857:	89 f0                	mov    %esi,%eax
  802859:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  80285f:	5b                   	pop    %ebx
  802860:	5e                   	pop    %esi
  802861:	5f                   	pop    %edi
  802862:	5d                   	pop    %ebp
  802863:	c3                   	ret    

00802864 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802864:	55                   	push   %ebp
  802865:	89 e5                	mov    %esp,%ebp
  802867:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  80286a:	8b 45 08             	mov    0x8(%ebp),%eax
  80286d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802870:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802877:	00 
  802878:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80287b:	89 04 24             	mov    %eax,(%esp)
  80287e:	e8 0d e4 ff ff       	call   800c90 <sys_cputs>
}
  802883:	c9                   	leave  
  802884:	c3                   	ret    

00802885 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802885:	55                   	push   %ebp
  802886:	89 e5                	mov    %esp,%ebp
  802888:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  80288b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80288f:	75 07                	jne    802898 <devcons_read+0x13>
  802891:	eb 2d                	jmp    8028c0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802893:	e8 bd e7 ff ff       	call   801055 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802898:	90                   	nop
  802899:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8028a0:	e8 b7 e3 ff ff       	call   800c5c <sys_cgetc>
  8028a5:	85 c0                	test   %eax,%eax
  8028a7:	74 ea                	je     802893 <devcons_read+0xe>
  8028a9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  8028ab:	85 c0                	test   %eax,%eax
  8028ad:	78 16                	js     8028c5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  8028af:	83 f8 04             	cmp    $0x4,%eax
  8028b2:	74 0c                	je     8028c0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  8028b4:	8b 45 0c             	mov    0xc(%ebp),%eax
  8028b7:	88 10                	mov    %dl,(%eax)
  8028b9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  8028be:	eb 05                	jmp    8028c5 <devcons_read+0x40>
  8028c0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8028c5:	c9                   	leave  
  8028c6:	c3                   	ret    

008028c7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  8028c7:	55                   	push   %ebp
  8028c8:	89 e5                	mov    %esp,%ebp
  8028ca:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  8028cd:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8028d0:	89 04 24             	mov    %eax,(%esp)
  8028d3:	e8 43 ed ff ff       	call   80161b <fd_alloc>
  8028d8:	85 c0                	test   %eax,%eax
  8028da:	78 3f                	js     80291b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  8028dc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8028e3:	00 
  8028e4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8028e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028eb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028f2:	e8 ff e6 ff ff       	call   800ff6 <sys_page_alloc>
  8028f7:	85 c0                	test   %eax,%eax
  8028f9:	78 20                	js     80291b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  8028fb:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802901:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802904:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802906:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802909:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802910:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802913:	89 04 24             	mov    %eax,(%esp)
  802916:	e8 d5 ec ff ff       	call   8015f0 <fd2num>
}
  80291b:	c9                   	leave  
  80291c:	c3                   	ret    

0080291d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80291d:	55                   	push   %ebp
  80291e:	89 e5                	mov    %esp,%ebp
  802920:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802923:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802926:	89 44 24 04          	mov    %eax,0x4(%esp)
  80292a:	8b 45 08             	mov    0x8(%ebp),%eax
  80292d:	89 04 24             	mov    %eax,(%esp)
  802930:	e8 58 ed ff ff       	call   80168d <fd_lookup>
  802935:	85 c0                	test   %eax,%eax
  802937:	78 11                	js     80294a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802939:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80293c:	8b 00                	mov    (%eax),%eax
  80293e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802944:	0f 94 c0             	sete   %al
  802947:	0f b6 c0             	movzbl %al,%eax
}
  80294a:	c9                   	leave  
  80294b:	c3                   	ret    

0080294c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  80294c:	55                   	push   %ebp
  80294d:	89 e5                	mov    %esp,%ebp
  80294f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802952:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802959:	00 
  80295a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80295d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802961:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802968:	e8 86 ef ff ff       	call   8018f3 <read>
	if (r < 0)
  80296d:	85 c0                	test   %eax,%eax
  80296f:	78 0f                	js     802980 <getchar+0x34>
		return r;
	if (r < 1)
  802971:	85 c0                	test   %eax,%eax
  802973:	7f 07                	jg     80297c <getchar+0x30>
  802975:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  80297a:	eb 04                	jmp    802980 <getchar+0x34>
		return -E_EOF;
	return c;
  80297c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802980:	c9                   	leave  
  802981:	c3                   	ret    
	...

00802984 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  802984:	55                   	push   %ebp
  802985:	89 e5                	mov    %esp,%ebp
  802987:	53                   	push   %ebx
  802988:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  80298b:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80298e:	a1 7c 70 80 00       	mov    0x80707c,%eax
  802993:	85 c0                	test   %eax,%eax
  802995:	74 10                	je     8029a7 <_panic+0x23>
		cprintf("%s: ", argv0);
  802997:	89 44 24 04          	mov    %eax,0x4(%esp)
  80299b:	c7 04 24 b1 33 80 00 	movl   $0x8033b1,(%esp)
  8029a2:	e8 1e d8 ff ff       	call   8001c5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8029a7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029aa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8029ae:	8b 45 08             	mov    0x8(%ebp),%eax
  8029b1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029b5:	a1 00 70 80 00       	mov    0x807000,%eax
  8029ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029be:	c7 04 24 b6 33 80 00 	movl   $0x8033b6,(%esp)
  8029c5:	e8 fb d7 ff ff       	call   8001c5 <cprintf>
	vcprintf(fmt, ap);
  8029ca:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8029ce:	8b 45 10             	mov    0x10(%ebp),%eax
  8029d1:	89 04 24             	mov    %eax,(%esp)
  8029d4:	e8 8b d7 ff ff       	call   800164 <vcprintf>
	cprintf("\n");
  8029d9:	c7 04 24 e7 30 80 00 	movl   $0x8030e7,(%esp)
  8029e0:	e8 e0 d7 ff ff       	call   8001c5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8029e5:	cc                   	int3   
  8029e6:	eb fd                	jmp    8029e5 <_panic+0x61>

008029e8 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  8029e8:	55                   	push   %ebp
  8029e9:	89 e5                	mov    %esp,%ebp
  8029eb:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  8029ee:	83 3d 78 70 80 00 00 	cmpl   $0x0,0x807078
  8029f5:	75 55                	jne    802a4c <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  8029f7:	e8 8d e6 ff ff       	call   801089 <sys_getenvid>
  8029fc:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802a03:	00 
  802a04:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802a0b:	ee 
  802a0c:	89 04 24             	mov    %eax,(%esp)
  802a0f:	e8 e2 e5 ff ff       	call   800ff6 <sys_page_alloc>
  802a14:	85 c0                	test   %eax,%eax
  802a16:	74 1c                	je     802a34 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802a18:	c7 44 24 08 d4 33 80 	movl   $0x8033d4,0x8(%esp)
  802a1f:	00 
  802a20:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802a27:	00 
  802a28:	c7 04 24 f8 33 80 00 	movl   $0x8033f8,(%esp)
  802a2f:	e8 50 ff ff ff       	call   802984 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802a34:	a1 74 70 80 00       	mov    0x807074,%eax
  802a39:	8b 40 4c             	mov    0x4c(%eax),%eax
  802a3c:	c7 44 24 04 58 2a 80 	movl   $0x802a58,0x4(%esp)
  802a43:	00 
  802a44:	89 04 24             	mov    %eax,(%esp)
  802a47:	e8 d4 e3 ff ff       	call   800e20 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802a4c:	8b 45 08             	mov    0x8(%ebp),%eax
  802a4f:	a3 78 70 80 00       	mov    %eax,0x807078
}
  802a54:	c9                   	leave  
  802a55:	c3                   	ret    
	...

00802a58 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802a58:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802a59:	a1 78 70 80 00       	mov    0x807078,%eax
	call *%eax
  802a5e:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802a60:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802a63:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802a68:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802a6c:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802a70:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802a72:	83 c4 08             	add    $0x8,%esp
    popal
  802a75:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802a76:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802a7a:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802a7b:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802a7f:	c3                   	ret    

00802a80 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802a80:	55                   	push   %ebp
  802a81:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802a83:	8b 45 08             	mov    0x8(%ebp),%eax
  802a86:	89 c2                	mov    %eax,%edx
  802a88:	c1 ea 16             	shr    $0x16,%edx
  802a8b:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802a92:	f6 c2 01             	test   $0x1,%dl
  802a95:	74 26                	je     802abd <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802a97:	c1 e8 0c             	shr    $0xc,%eax
  802a9a:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802aa1:	a8 01                	test   $0x1,%al
  802aa3:	74 18                	je     802abd <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802aa5:	c1 e8 0c             	shr    $0xc,%eax
  802aa8:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802aab:	c1 e2 02             	shl    $0x2,%edx
  802aae:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802ab3:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802ab8:	0f b7 c0             	movzwl %ax,%eax
  802abb:	eb 05                	jmp    802ac2 <pageref+0x42>
  802abd:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802ac2:	5d                   	pop    %ebp
  802ac3:	c3                   	ret    
	...

00802ad0 <__udivdi3>:
  802ad0:	55                   	push   %ebp
  802ad1:	89 e5                	mov    %esp,%ebp
  802ad3:	57                   	push   %edi
  802ad4:	56                   	push   %esi
  802ad5:	83 ec 10             	sub    $0x10,%esp
  802ad8:	8b 45 14             	mov    0x14(%ebp),%eax
  802adb:	8b 55 08             	mov    0x8(%ebp),%edx
  802ade:	8b 75 10             	mov    0x10(%ebp),%esi
  802ae1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802ae4:	85 c0                	test   %eax,%eax
  802ae6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802ae9:	75 35                	jne    802b20 <__udivdi3+0x50>
  802aeb:	39 fe                	cmp    %edi,%esi
  802aed:	77 61                	ja     802b50 <__udivdi3+0x80>
  802aef:	85 f6                	test   %esi,%esi
  802af1:	75 0b                	jne    802afe <__udivdi3+0x2e>
  802af3:	b8 01 00 00 00       	mov    $0x1,%eax
  802af8:	31 d2                	xor    %edx,%edx
  802afa:	f7 f6                	div    %esi
  802afc:	89 c6                	mov    %eax,%esi
  802afe:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802b01:	31 d2                	xor    %edx,%edx
  802b03:	89 f8                	mov    %edi,%eax
  802b05:	f7 f6                	div    %esi
  802b07:	89 c7                	mov    %eax,%edi
  802b09:	89 c8                	mov    %ecx,%eax
  802b0b:	f7 f6                	div    %esi
  802b0d:	89 c1                	mov    %eax,%ecx
  802b0f:	89 fa                	mov    %edi,%edx
  802b11:	89 c8                	mov    %ecx,%eax
  802b13:	83 c4 10             	add    $0x10,%esp
  802b16:	5e                   	pop    %esi
  802b17:	5f                   	pop    %edi
  802b18:	5d                   	pop    %ebp
  802b19:	c3                   	ret    
  802b1a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802b20:	39 f8                	cmp    %edi,%eax
  802b22:	77 1c                	ja     802b40 <__udivdi3+0x70>
  802b24:	0f bd d0             	bsr    %eax,%edx
  802b27:	83 f2 1f             	xor    $0x1f,%edx
  802b2a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802b2d:	75 39                	jne    802b68 <__udivdi3+0x98>
  802b2f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802b32:	0f 86 a0 00 00 00    	jbe    802bd8 <__udivdi3+0x108>
  802b38:	39 f8                	cmp    %edi,%eax
  802b3a:	0f 82 98 00 00 00    	jb     802bd8 <__udivdi3+0x108>
  802b40:	31 ff                	xor    %edi,%edi
  802b42:	31 c9                	xor    %ecx,%ecx
  802b44:	89 c8                	mov    %ecx,%eax
  802b46:	89 fa                	mov    %edi,%edx
  802b48:	83 c4 10             	add    $0x10,%esp
  802b4b:	5e                   	pop    %esi
  802b4c:	5f                   	pop    %edi
  802b4d:	5d                   	pop    %ebp
  802b4e:	c3                   	ret    
  802b4f:	90                   	nop
  802b50:	89 d1                	mov    %edx,%ecx
  802b52:	89 fa                	mov    %edi,%edx
  802b54:	89 c8                	mov    %ecx,%eax
  802b56:	31 ff                	xor    %edi,%edi
  802b58:	f7 f6                	div    %esi
  802b5a:	89 c1                	mov    %eax,%ecx
  802b5c:	89 fa                	mov    %edi,%edx
  802b5e:	89 c8                	mov    %ecx,%eax
  802b60:	83 c4 10             	add    $0x10,%esp
  802b63:	5e                   	pop    %esi
  802b64:	5f                   	pop    %edi
  802b65:	5d                   	pop    %ebp
  802b66:	c3                   	ret    
  802b67:	90                   	nop
  802b68:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b6c:	89 f2                	mov    %esi,%edx
  802b6e:	d3 e0                	shl    %cl,%eax
  802b70:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802b73:	b8 20 00 00 00       	mov    $0x20,%eax
  802b78:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802b7b:	89 c1                	mov    %eax,%ecx
  802b7d:	d3 ea                	shr    %cl,%edx
  802b7f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b83:	0b 55 ec             	or     -0x14(%ebp),%edx
  802b86:	d3 e6                	shl    %cl,%esi
  802b88:	89 c1                	mov    %eax,%ecx
  802b8a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802b8d:	89 fe                	mov    %edi,%esi
  802b8f:	d3 ee                	shr    %cl,%esi
  802b91:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b95:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802b98:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802b9b:	d3 e7                	shl    %cl,%edi
  802b9d:	89 c1                	mov    %eax,%ecx
  802b9f:	d3 ea                	shr    %cl,%edx
  802ba1:	09 d7                	or     %edx,%edi
  802ba3:	89 f2                	mov    %esi,%edx
  802ba5:	89 f8                	mov    %edi,%eax
  802ba7:	f7 75 ec             	divl   -0x14(%ebp)
  802baa:	89 d6                	mov    %edx,%esi
  802bac:	89 c7                	mov    %eax,%edi
  802bae:	f7 65 e8             	mull   -0x18(%ebp)
  802bb1:	39 d6                	cmp    %edx,%esi
  802bb3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802bb6:	72 30                	jb     802be8 <__udivdi3+0x118>
  802bb8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802bbb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802bbf:	d3 e2                	shl    %cl,%edx
  802bc1:	39 c2                	cmp    %eax,%edx
  802bc3:	73 05                	jae    802bca <__udivdi3+0xfa>
  802bc5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802bc8:	74 1e                	je     802be8 <__udivdi3+0x118>
  802bca:	89 f9                	mov    %edi,%ecx
  802bcc:	31 ff                	xor    %edi,%edi
  802bce:	e9 71 ff ff ff       	jmp    802b44 <__udivdi3+0x74>
  802bd3:	90                   	nop
  802bd4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bd8:	31 ff                	xor    %edi,%edi
  802bda:	b9 01 00 00 00       	mov    $0x1,%ecx
  802bdf:	e9 60 ff ff ff       	jmp    802b44 <__udivdi3+0x74>
  802be4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802be8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802beb:	31 ff                	xor    %edi,%edi
  802bed:	89 c8                	mov    %ecx,%eax
  802bef:	89 fa                	mov    %edi,%edx
  802bf1:	83 c4 10             	add    $0x10,%esp
  802bf4:	5e                   	pop    %esi
  802bf5:	5f                   	pop    %edi
  802bf6:	5d                   	pop    %ebp
  802bf7:	c3                   	ret    
	...

00802c00 <__umoddi3>:
  802c00:	55                   	push   %ebp
  802c01:	89 e5                	mov    %esp,%ebp
  802c03:	57                   	push   %edi
  802c04:	56                   	push   %esi
  802c05:	83 ec 20             	sub    $0x20,%esp
  802c08:	8b 55 14             	mov    0x14(%ebp),%edx
  802c0b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802c0e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802c11:	8b 75 0c             	mov    0xc(%ebp),%esi
  802c14:	85 d2                	test   %edx,%edx
  802c16:	89 c8                	mov    %ecx,%eax
  802c18:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802c1b:	75 13                	jne    802c30 <__umoddi3+0x30>
  802c1d:	39 f7                	cmp    %esi,%edi
  802c1f:	76 3f                	jbe    802c60 <__umoddi3+0x60>
  802c21:	89 f2                	mov    %esi,%edx
  802c23:	f7 f7                	div    %edi
  802c25:	89 d0                	mov    %edx,%eax
  802c27:	31 d2                	xor    %edx,%edx
  802c29:	83 c4 20             	add    $0x20,%esp
  802c2c:	5e                   	pop    %esi
  802c2d:	5f                   	pop    %edi
  802c2e:	5d                   	pop    %ebp
  802c2f:	c3                   	ret    
  802c30:	39 f2                	cmp    %esi,%edx
  802c32:	77 4c                	ja     802c80 <__umoddi3+0x80>
  802c34:	0f bd ca             	bsr    %edx,%ecx
  802c37:	83 f1 1f             	xor    $0x1f,%ecx
  802c3a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802c3d:	75 51                	jne    802c90 <__umoddi3+0x90>
  802c3f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802c42:	0f 87 e0 00 00 00    	ja     802d28 <__umoddi3+0x128>
  802c48:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c4b:	29 f8                	sub    %edi,%eax
  802c4d:	19 d6                	sbb    %edx,%esi
  802c4f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802c52:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c55:	89 f2                	mov    %esi,%edx
  802c57:	83 c4 20             	add    $0x20,%esp
  802c5a:	5e                   	pop    %esi
  802c5b:	5f                   	pop    %edi
  802c5c:	5d                   	pop    %ebp
  802c5d:	c3                   	ret    
  802c5e:	66 90                	xchg   %ax,%ax
  802c60:	85 ff                	test   %edi,%edi
  802c62:	75 0b                	jne    802c6f <__umoddi3+0x6f>
  802c64:	b8 01 00 00 00       	mov    $0x1,%eax
  802c69:	31 d2                	xor    %edx,%edx
  802c6b:	f7 f7                	div    %edi
  802c6d:	89 c7                	mov    %eax,%edi
  802c6f:	89 f0                	mov    %esi,%eax
  802c71:	31 d2                	xor    %edx,%edx
  802c73:	f7 f7                	div    %edi
  802c75:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c78:	f7 f7                	div    %edi
  802c7a:	eb a9                	jmp    802c25 <__umoddi3+0x25>
  802c7c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c80:	89 c8                	mov    %ecx,%eax
  802c82:	89 f2                	mov    %esi,%edx
  802c84:	83 c4 20             	add    $0x20,%esp
  802c87:	5e                   	pop    %esi
  802c88:	5f                   	pop    %edi
  802c89:	5d                   	pop    %ebp
  802c8a:	c3                   	ret    
  802c8b:	90                   	nop
  802c8c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c90:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802c94:	d3 e2                	shl    %cl,%edx
  802c96:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802c99:	ba 20 00 00 00       	mov    $0x20,%edx
  802c9e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802ca1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ca4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ca8:	89 fa                	mov    %edi,%edx
  802caa:	d3 ea                	shr    %cl,%edx
  802cac:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cb0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802cb3:	d3 e7                	shl    %cl,%edi
  802cb5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802cb9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802cbc:	89 f2                	mov    %esi,%edx
  802cbe:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802cc1:	89 c7                	mov    %eax,%edi
  802cc3:	d3 ea                	shr    %cl,%edx
  802cc5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cc9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802ccc:	89 c2                	mov    %eax,%edx
  802cce:	d3 e6                	shl    %cl,%esi
  802cd0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802cd4:	d3 ea                	shr    %cl,%edx
  802cd6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cda:	09 d6                	or     %edx,%esi
  802cdc:	89 f0                	mov    %esi,%eax
  802cde:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802ce1:	d3 e7                	shl    %cl,%edi
  802ce3:	89 f2                	mov    %esi,%edx
  802ce5:	f7 75 f4             	divl   -0xc(%ebp)
  802ce8:	89 d6                	mov    %edx,%esi
  802cea:	f7 65 e8             	mull   -0x18(%ebp)
  802ced:	39 d6                	cmp    %edx,%esi
  802cef:	72 2b                	jb     802d1c <__umoddi3+0x11c>
  802cf1:	39 c7                	cmp    %eax,%edi
  802cf3:	72 23                	jb     802d18 <__umoddi3+0x118>
  802cf5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cf9:	29 c7                	sub    %eax,%edi
  802cfb:	19 d6                	sbb    %edx,%esi
  802cfd:	89 f0                	mov    %esi,%eax
  802cff:	89 f2                	mov    %esi,%edx
  802d01:	d3 ef                	shr    %cl,%edi
  802d03:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802d07:	d3 e0                	shl    %cl,%eax
  802d09:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802d0d:	09 f8                	or     %edi,%eax
  802d0f:	d3 ea                	shr    %cl,%edx
  802d11:	83 c4 20             	add    $0x20,%esp
  802d14:	5e                   	pop    %esi
  802d15:	5f                   	pop    %edi
  802d16:	5d                   	pop    %ebp
  802d17:	c3                   	ret    
  802d18:	39 d6                	cmp    %edx,%esi
  802d1a:	75 d9                	jne    802cf5 <__umoddi3+0xf5>
  802d1c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802d1f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802d22:	eb d1                	jmp    802cf5 <__umoddi3+0xf5>
  802d24:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802d28:	39 f2                	cmp    %esi,%edx
  802d2a:	0f 82 18 ff ff ff    	jb     802c48 <__umoddi3+0x48>
  802d30:	e9 1d ff ff ff       	jmp    802c52 <__umoddi3+0x52>
